From b28fa86e337db2bf37234644896027f34141c763 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Fri, 25 Feb 2022 23:02:58 -0700 Subject: [PATCH] Update ad filter Recent changes to ads in search results caused Whoogle to display ads for certain searches. In particular, ads recently started appearing grouped into one div, as opposed to a singular ad per div. This was accompanied by the div label "ads" (instead of just "ad"), which threw off the existing ad filter. The ad keyword blacklist has been updated accordingly, and has been enhanced to only check against alpha chars for each label. This only seems to have affected English language searches, and only for very specific searches. --- app/utils/results.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/utils/results.py b/app/utils/results.py index 48aa857..38e92e0 100644 --- a/app/utils/results.py +++ b/app/utils/results.py @@ -18,10 +18,11 @@ BLANK_B64 = ('data:image/png;base64,' # Ad keywords BLACKLIST = [ - 'ad', 'anuncio', 'annuncio', 'annonce', 'Anzeige', '广告', '廣告', 'Reklama', - 'Реклама', 'Anunț', '광고', 'annons', 'Annonse', 'Iklan', '広告', 'Augl.', - 'Mainos', 'Advertentie', 'إعلان', 'Գովազդ', 'विज्ञापन', 'Reklam', 'آگهی', - 'Reklāma', 'Reklaam', 'Διαφήμιση', 'מודעה', 'Hirdetés', 'Anúncio' + 'ad', 'ads', 'anuncio', 'annuncio', 'annonce', 'Anzeige', '广告', '廣告', + 'Reklama', 'Реклама', 'Anunț', '광고', 'annons', 'Annonse', 'Iklan', + '広告', 'Augl.', 'Mainos', 'Advertentie', 'إعلان', 'Գովազդ', 'विज्ञापन', + 'Reklam', 'آگهی', 'Reklāma', 'Reklaam', 'Διαφήμιση', 'מודעה', 'Hirdetés', + 'Anúncio' ] SITE_ALTS = { @@ -89,7 +90,8 @@ def has_ad_content(element: str) -> bool: bool: True/False for the element containing an ad """ - return (element.upper() in (value.upper() for value in BLACKLIST) + element_str = ''.join(filter(str.isalpha, element)) + return (element_str.upper() in (value.upper() for value in BLACKLIST) or 'ⓘ' in element)