juliomalegria / python-craigslist

Simple Craigslist wrapper
MIT No Attribution
387 stars 165 forks source link

[question] Is there an easy way to fetch the images of a listing? #96

Closed bevensteven closed 3 years ago

bevensteven commented 3 years ago

Sweet project!

After finding a bunch of listings, I'm wondering if there's a low-effort way to retrieve a listing's attached images? Can't think of anything off the top of my head other than scraping those images.

Thanks!

irahorecka commented 3 years ago

Yes, there is. Add keyword argument include_details=True when iterating through get_results. A list of image urls will be assigned to the key "images" in the output value.

# ...
for result in cl_h.get_results(sort_by='newest', geotagged=False, include_details=True):
    print(result['images'])
# ...
juliomalegria commented 3 years ago

Thanks @bevensteven for using the project. As @irahorecka pointed out, when getting the details of all posts (include_details=TRue), all URLs to images are included.

Thanks Ira for helping out!