Skip to content

Commit

Permalink
added exception handler in the event of no images found
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Ennis committed Jun 1, 2015
1 parent 21137c4 commit e9f1929
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions artexin/preprocessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"""

from bs4 import BeautifulSoup

from . import __version__ as _version, __author__ as _author


Expand Down Expand Up @@ -166,7 +165,10 @@ def pp_dwelle(html):
soup = BeautifulSoup(html)
intro = soup.find_all('p', {'class': 'intro'})[0]
ppicture = soup.new_tag('p')
picture = soup.find_all('div', {'class': 'picBox'})[0].a.img
try:
picture = soup.find_all('div', {'class': 'picBox'})[0].a.img
except IndexError:
print('No image found. This is likely expected behaviour.')
ppicture.append(picture)
long_text = soup.find_all('div', {'class': 'longText'})[0]
pdate = soup.new_tag('p')
Expand Down

0 comments on commit e9f1929

Please sign in to comment.