Update minimal mode for new Google formatting (#637)
Google's latest formatting changes broke the modifications made when enabling `WHOOGLE_MINIMAL`. This updates the result filtering to work with the new changes. Fixes #634main
parent
b393e68d1d
commit
500942cb99
|
@ -12,6 +12,8 @@ import urllib.parse as urlparse
|
||||||
from urllib.parse import parse_qs
|
from urllib.parse import parse_qs
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
minimal_mode_sections = ['Top stories', 'Images', 'People also ask']
|
||||||
|
|
||||||
|
|
||||||
def extract_q(q_str: str, href: str) -> str:
|
def extract_q(q_str: str, href: str) -> str:
|
||||||
"""Extracts the 'q' element from a result link. This is typically
|
"""Extracts the 'q' element from a result link. This is typically
|
||||||
|
@ -169,7 +171,11 @@ class Filter:
|
||||||
for result in self.main_divs:
|
for result in self.main_divs:
|
||||||
result_children = pull_child_divs(result)
|
result_children = pull_child_divs(result)
|
||||||
if minimal_mode:
|
if minimal_mode:
|
||||||
if len(result_children) in (1, 3):
|
if any(f">{x}</span" in str(s) for s in result_children
|
||||||
|
for x in minimal_mode_sections):
|
||||||
|
result.decompose()
|
||||||
|
continue
|
||||||
|
if len(result_children) < self.RESULT_CHILD_LIMIT:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
if len(result_children) < self.RESULT_CHILD_LIMIT:
|
if len(result_children) < self.RESULT_CHILD_LIMIT:
|
||||||
|
|
Loading…
Reference in New Issue