From dcd93d48696dca4d9843e596a17bd4472345a621 Mon Sep 17 00:00:00 2001 From: Ben Busby <ben.busby7@gmail.com> Date: Wed, 29 Apr 2020 10:03:34 -0600 Subject: [PATCH] Fixed filter params, updated search button text --- app/filter.py | 7 ++++--- app/templates/index.html | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/filter.py b/app/filter.py index 859dc6e..7b639fe 100644 --- a/app/filter.py +++ b/app/filter.py @@ -54,6 +54,8 @@ class Filter: def remove_ads(self, soup): main_divs = soup.find('div', {'id': 'main'}) + if main_divs is None: + return result_divs = main_divs.find_all('div', recursive=False) # Only ads/sponsored content use classes in the list of result divs @@ -114,9 +116,8 @@ class Filter: new_search = '/search?q=' + enc_result.decode() query_params = parse_qs(urlparse.urlparse(href).query) - allowed_params = [_ for _ in query_params if _ in VALID_PARAMS] - for param in allowed_params: - param_val = query_params[param][0] + for param in VALID_PARAMS: + param_val = query_params[param][0] if param in query_params else '' new_search += '&' + param + '=' + param_val a['href'] = new_search continue diff --git a/app/templates/index.html b/app/templates/index.html index 647f4dc..6edef64 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -28,7 +28,7 @@ <form action="/search" method="post"> <div class="search-fields"> <input type="text" name="q" id="search-bar"> - <input type="submit" id="search-submit" value="Submit"> + <input type="submit" id="search-submit" value="Search"> </div> </form> <br/>