From b83f14be2679a1919a0c789be40b8990c06d1932 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Wed, 29 Apr 2020 11:18:07 -0600 Subject: [PATCH] Fixed image href filter Needed to be checking against img attrs, not just the img object itself --- app/filter.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/filter.py b/app/filter.py index 7b639fe..e057239 100644 --- a/app/filter.py +++ b/app/filter.py @@ -64,7 +64,7 @@ class Filter: div.decompose() def update_image_paths(self, soup): - for img in [_ for _ in soup.find_all('img') if 'src' in _]: + for img in [_ for _ in soup.find_all('img') if 'src' in _.attrs]: img_src = img['src'] if img_src.startswith('//'): img_src = 'https:' + img_src @@ -103,7 +103,7 @@ class Filter: def update_links(self, soup): # Replace hrefs with only the intended destination (no "utm" type tags) for a in soup.find_all('a', href=True): - href = a['href'] + href = a['href'].replace('https://www.google.com', '') if '/advanced_search' in href: a.decompose() continue @@ -147,6 +147,8 @@ class Filter: if self.nojs: gen_nojs(soup, query_link, a) + a['href'] = href + def gen_nojs(soup, link, sibling): nojs_link = soup.new_tag('a')