juliomalegria / python-craigslist

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

Crash on include_details when post has been deleted #73

Closed wolfgang42 closed 4 years ago

wolfgang42 commented 4 years ago
GET https://sfbay.craigslist.org/sfc/apa/d/san-francisco-open-sun-1245pm-130pm/7037808940.html
Response code: 200
Geotagging result ...
Adding details to result...
Traceback (most recent call last):
  [...]
  File ".../venv/lib/python3.6/site-packages/craigslist/__init__.py", line 245, in get_results
    self.include_details(result, detail_soup)
  File ".../venv/lib/python3.6/site-packages/craigslist/__init__.py", line 282, in include_details
    body_text = (getattr(e, 'text', e) for e in body
TypeError: 'NoneType' object is not iterable

The relevant page causing the crash contains the following HTML:

<section class="body">
<div id="userbody">
<div class="prevnext js-only">
<a class="prev">◀  prev </a>
<a class="backup" title="back to search">▲</a>
<a class="next"> next ▶ </a>
</div>
<span id="has_been_removed"></span>
<div class="removed">
<h2>
This posting has been deleted by its author.
    </h2>
</div>
</div>
</section>
juliomalegria commented 4 years ago

Thanks for reporting this @wolfgang42. Let me take a look into this case, and I'll do the fix.