Clean "Show more results" of all site blocks (#646)
parent
11099f7b1d
commit
502067addc
|
@ -119,9 +119,20 @@ class Filter:
|
||||||
header = soup.find('header')
|
header = soup.find('header')
|
||||||
if header:
|
if header:
|
||||||
header.decompose()
|
header.decompose()
|
||||||
|
self.remove_site_blocks(soup)
|
||||||
return 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:
|
def remove_ads(self) -> None:
|
||||||
"""Removes ads found in the list of search result divs
|
"""Removes ads found in the list of search result divs
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue