Fixed image href filter

Needed to be checking against img attrs, not just the img object itself
main
Ben Busby 2020-04-29 11:18:07 -06:00
parent 6d38abd1b4
commit b83f14be26
1 changed files with 4 additions and 2 deletions

View File

@ -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')