juliomalegria / python-craigslist

Simple Craigslist wrapper
MIT No Attribution
389 stars 116 forks source link

AttributeError: 'NoneType' object has no attribute 'text' #17

Closed nguillermin closed 8 years ago

nguillermin commented 8 years ago

This was run in ipython notebook (python 2.7.11)

/Users/megablanc/Library/Python/2.7/lib/python/site-packages/craigslist/__init__.pyc in get_results(self, limit, sort_by, geotagged)
    158                 price = row.find('span', {'class': 'price'})
    159                 where = row.find('small')
--> 160                 p_text = row.find('span', {'class': 'p'}).text
    161 
    162                 result = {'id': id,

AttributeError: 'NoneType' object has no attribute 'text'

Full code:

from craigslist import CraigslistHousing

cl = CraigslistHousing(site='boston', area='gbs', category='roo',
                         filters={'max_price': 2000, 'min_price': 500})

results = cl.get_results(sort_by='newest', geotagged=True, limit=20)
for result in results:
    print result

I get a couple results but eventually it crashes.

nguillermin commented 8 years ago

It seems like this particular line of code was changed in the repo...is the pip version out of date?

WIRUT commented 8 years ago

Seems like it. I had the same issue until I re-ran my pip installer with: pip install git+https://github.com/juliomalegria/python-craigslist

Hope this simple solution helps others who had the same issue.

mrxinu commented 8 years ago

The solution from @WIRUT worked great with a fresh virtualenv.

juliomalegria commented 8 years ago

Yep, this is the same as #16. I've made the fix already, but haven't released a new version to PIP. I was waiting for more fixes/improvements, but if this is affecting to people already, I'll go ahead and make a new release soon.