diff --git a/app/filter.py b/app/filter.py index c56ab8d..82fc1b8 100644 --- a/app/filter.py +++ b/app/filter.py @@ -313,12 +313,19 @@ class Filter: urls = item.find('a')['href'].split('&imgrefurl=') img_url = urlparse.unquote(urls[0].replace('/imgres?imgurl=', '')) - webpage = urlparse.unquote(urls[1].split('&')[0]) + + try: + # Try to strip out only the necessary part of the web page link + web_page = urlparse.unquote(urls[1].split('&')[0]) + except IndexError: + web_page = urlparse.unquote(urls[1]) + img_tbn = urlparse.unquote(item.find('a').find('img')['src']) + results.append({ - 'domain': urlparse.urlparse(webpage).netloc, + 'domain': urlparse.urlparse(web_page).netloc, 'img_url': img_url, - 'webpage': webpage, + 'web_page': web_page, 'img_tbn': img_tbn }) diff --git a/app/templates/imageresults.html b/app/templates/imageresults.html index 17ee98a..fc09b29 100644 --- a/app/templates/imageresults.html +++ b/app/templates/imageresults.html @@ -64,7 +64,7 @@
-
+
|
-
+
|