From 6a82f6e1adad39157c7a82613e1bdfb9d5dcd82c Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Mon, 6 Apr 2020 18:20:44 +0000 Subject: [PATCH] Added filtering of sponsored content --- app/routes.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/routes.py b/app/routes.py index bcfb725..ed80157 100644 --- a/app/routes.py +++ b/app/routes.py @@ -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)