Added filtering of sponsored content

main
Ben Busby 2020-04-06 18:20:44 +00:00
parent 066c253c4d
commit 6a82f6e1ad
1 changed files with 3 additions and 2 deletions

View File

@ -99,11 +99,12 @@ def search():
soup = BeautifulSoup(get_body, 'html.parser')
# Remove all ads (TODO: Ad specific div class may change over time, look into a more generic method)
# Remove all ads (TODO: Ad specific div classes probably change over time, look into a more generic method)
main_divs = soup.find('div', {'id': 'main'})
if main_divs is not None:
ad_divs = main_divs.findAll('div', {'class': 'ZINbbc'}, recursive=False)
for div in ad_divs:
sponsored_divs = main_divs.findAll('div', {'class': 'D1fz0e'}, recursive=False)
for div in ad_divs + sponsored_divs:
div.decompose()
# Remove unnecessary button(s)