Better error handling for mime parsers. #264.

This commit is contained in:
Michael Lazar
2016-07-26 23:47:52 -07:00
parent 663d6ee5b9
commit 04a6d31ad9
2 changed files with 13 additions and 8 deletions

View File

@@ -153,7 +153,10 @@ class ImgurAlbumMIMEParser(BaseMIMEParser):
urls = []
for div in soup.find_all('div', class_='post-image'):
urls.append('http:' + div.find('img').get('src'))
img = div.find('img')
src = img.get('src') if img else None
if src:
urls.append('http:{0}'.format(src))
if urls:
return " ".join(urls), 'image/x-imgur-album'