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/request.py b/app/request.py index 6744fe2..68e30d8 100644 --- a/app/request.py +++ b/app/request.py @@ -157,7 +157,8 @@ class Request: self.language = ( config.lang_search if config.lang_search else '' ) - self.mobile = 'Android' in normal_ua or 'iPhone' in normal_ua + self.mobile = bool(normal_ua) and ('Android' in normal_ua + or 'iPhone' in normal_ua) self.modified_user_agent = gen_user_agent(self.mobile) if not self.mobile: self.modified_user_agent_mobile = gen_user_agent(True) 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 @@
-
+
|
-
+
|