diff --git a/app/models/config.py b/app/models/config.py
index e69e037..4fe0092 100644
--- a/app/models/config.py
+++ b/app/models/config.py
@@ -128,7 +128,7 @@ class Config:
{'name': 'Fiji', 'value': 'countryFJ'},
{'name': 'Finland', 'value': 'countryFI'},
{'name': 'France', 'value': 'countryFR'},
- {'name': 'France\, Metropolitan', 'value': 'countryFX'},
+ {'name': r'France\, Metropolitan', 'value': 'countryFX'},
{'name': 'French Guiana', 'value': 'countryGF'},
{'name': 'French Polynesia', 'value': 'countryPF'},
{'name': 'French Southern Territories', 'value': 'countryTF'},
@@ -167,7 +167,8 @@ class Config:
{'name': 'Kazakhstan', 'value': 'countryKZ'},
{'name': 'Kenya', 'value': 'countryKE'},
{'name': 'Kiribati', 'value': 'countryKI'},
- {'name': 'Korea, Democratic People\'s Republic of', 'value': 'countryKP'},
+ {'name': 'Korea, Democratic People\'s Republic of',
+ 'value': 'countryKP'},
{'name': 'Korea, Republic of', 'value': 'countryKR'},
{'name': 'Kuwait', 'value': 'countryKW'},
{'name': 'Kyrgyzstan', 'value': 'countryKG'},
@@ -181,7 +182,8 @@ class Config:
{'name': 'Lithuania', 'value': 'countryLT'},
{'name': 'Luxembourg', 'value': 'countryLU'},
{'name': 'Macao', 'value': 'countryMO'},
- {'name': 'Macedonia, the Former Yugosalv Republic of', 'value': 'countryMK'},
+ {'name': 'Macedonia, the Former Yugosalv Republic of',
+ 'value': 'countryMK'},
{'name': 'Madagascar', 'value': 'countryMG'},
{'name': 'Malawi', 'value': 'countryMW'},
{'name': 'Malaysia', 'value': 'countryMY'},
@@ -253,7 +255,8 @@ class Config:
{'name': 'Solomon Islands', 'value': 'countrySB'},
{'name': 'Somalia', 'value': 'countrySO'},
{'name': 'South Africa', 'value': 'countryZA'},
- {'name': 'South Georgia and the South Sandwich Islands', 'value': 'countryGS'},
+ {'name': 'South Georgia and the South Sandwich Islands',
+ 'value': 'countryGS'},
{'name': 'Spain', 'value': 'countryES'},
{'name': 'Sri Lanka', 'value': 'countryLK'},
{'name': 'Sudan', 'value': 'countrySD'},
@@ -310,6 +313,12 @@ class Config:
self.alts = False
self.new_tab = False
self.get_only = False
+ self.safe_keys = [
+ 'lang_search',
+ 'lang_interface',
+ 'ctry',
+ 'dark'
+ ]
for key, value in kwargs.items():
setattr(self, key, value)
@@ -338,12 +347,7 @@ class Config:
array
"""
- return key in [
- 'lang_search',
- 'lang_interface',
- 'ctry',
- 'dark'
- ]
+ return key in self.safe_keys
def from_params(self, params) -> 'Config':
"""Modify user config with search parameters. This is primarily
diff --git a/app/utils/filter_utils.py b/app/utils/filter_utils.py
index 0efb4ff..877c38c 100644
--- a/app/utils/filter_utils.py
+++ b/app/utils/filter_utils.py
@@ -7,14 +7,16 @@ SKIP_ARGS = ['ref_src', 'utm']
FULL_RES_IMG = '
Full Image'
GOOG_IMG = '/images/branding/searchlogo/1x/googlelogo'
LOGO_URL = GOOG_IMG + '_desk'
-BLANK_B64 = '''
-data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAQAAAAnOwc2AAAAD0lEQVR42mNkwAIYh7IgAAVVAAuInjI5AAAAAElFTkSuQmCC
-'''
+BLANK_B64 = ('data:image/png;base64,'
+ 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAQAAAAnOwc2AAAAD0lEQVR42mNkw'
+ 'AIYh7IgAAVVAAuInjI5AAAAAElFTkSuQmCC')
+# 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', 'anuncio', 'annuncio', 'annonce', 'Anzeige', '广告', '廣告', 'Reklama',
+ 'Реклама', 'Anunț', '광고', 'annons', 'Annonse', 'Iklan', '広告', 'Augl.',
+ 'Mainos', 'Advertentie', 'إعلان', 'Գովազդ', 'विज्ञापन', 'Reklam', 'آگهی',
+ 'Reklāma', 'Reklaam', 'Διαφήμιση', 'מודעה', 'Hirdetés', 'Anúncio'
]
SITE_ALTS = {
@@ -25,7 +27,8 @@ SITE_ALTS = {
def has_ad_content(element: str):
- return element.upper() in (value.upper() for value in BLACKLIST) or 'ⓘ' in element
+ return element.upper() in (value.upper() for value in BLACKLIST) \
+ or 'ⓘ' in element
def get_first_link(soup):
diff --git a/app/utils/routing_utils.py b/app/utils/routing_utils.py
index 703b7e0..3822d48 100644
--- a/app/utils/routing_utils.py
+++ b/app/utils/routing_utils.py
@@ -1,25 +1,26 @@
from app.filter import Filter, get_first_link
from app.utils.session_utils import generate_user_keys
from app.request import gen_query
-from bs4 import BeautifulSoup
+from bs4 import BeautifulSoup as bsoup
from cryptography.fernet import Fernet, InvalidToken
from flask import g
from typing import Any, Tuple
-
TOR_BANNER = '