juliomalegria / python-craigslist

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

Images not being detected #78

Closed dan-osull closed 4 years ago

dan-osull commented 4 years ago

Hey,

Thanks very much for the package!

I noticed the other day that CraigslistForSale results weren't being correctly populated with images.

I ran through the code with a debugger.

It looks like everything is OK until this line:

if 'src' not in img: # Some posts contain empty <img> tags.

It seems to always evaluate to True.

This is the type of img:

<class 'bs4.element.Tag'>

I wonder if something recently changed in Beautiful Soup?

This seems to fix the problem for me:

if 'src' not in str(img):

Or maybe this is better?

if 'src' not in img.attrs.keys():

Versions:

Python 3.8.2 on Linux beautifulsoup4==4.9.1 python-craigslist==1.0.8

juliomalegria commented 4 years ago

Thanks so much @weebsnore for reporting this! Seems to be that the package has been having an issue with images for some time. I've fixed it and already released version 1.0.10 with the fix. Thanks again!