Quick improvement to ad removal

main
Ben Busby 2020-05-29 13:21:53 -06:00
parent cb18bc6ccc
commit 71ba00785f
1 changed files with 3 additions and 4 deletions

View File

@ -111,10 +111,9 @@ class Filter:
return return
result_divs = main_divs.find_all('div', recursive=False) result_divs = main_divs.find_all('div', recursive=False)
# Only ads/sponsored content use classes in the list of result divs for div in [_ for _ in result_divs]:
ad_divs = [ad_div for ad_div in result_divs if 'class' in ad_div.attrs] has_ad = len([_ for _ in div.find_all('span', recursive=True) if 'ad' == _.text.lower()])
for div in ad_divs: _ = div.decompose() if has_ad else None
div.decompose()
def update_image_paths(self, soup): def update_image_paths(self, soup):
for img in [_ for _ in soup.find_all('img') if 'src' in _.attrs]: for img in [_ for _ in soup.find_all('img') if 'src' in _.attrs]: