From 502067addcc83d57b998983f452cd056836efcbb Mon Sep 17 00:00:00 2001 From: DUO Labs Date: Tue, 8 Feb 2022 12:57:00 -0500 Subject: [PATCH] Clean "Show more results" of all site blocks (#646) --- app/filter.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/filter.py b/app/filter.py index 94aab09..66cced7 100644 --- a/app/filter.py +++ b/app/filter.py @@ -119,9 +119,20 @@ class Filter: header = soup.find('header') if header: header.decompose() - + self.remove_site_blocks(soup) return soup + def remove_site_blocks(self, soup) -> None: + if not self.config.block: + return + search_string = ' '.join(['-site:' + + _ for _ in self.config.block.split(',')]) + selected = soup.body.findAll(text=re.compile(search_string)) + + for result in selected: + result.string.replace_with(result.string.replace( + search_string, '')) + def remove_ads(self) -> None: """Removes ads found in the list of search result divs