Update minimal mode for new Google formatting

This commit is contained in:
DUO Labs 2022-02-01 20:28:42 -05:00 committed by GitHub
parent 63301efb28
commit ce83bffc6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,6 +12,7 @@ import urllib.parse as urlparse
from urllib.parse import parse_qs
import os
minimal_mode_sections = ['Top stories','Images','People also ask']
def extract_q(q_str: str, href: str) -> str:
"""Extracts the 'q' element from a result link. This is typically
@ -169,7 +170,10 @@ class Filter:
for result in self.main_divs:
result_children = pull_child_divs(result)
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
else:
if len(result_children) < self.RESULT_CHILD_LIMIT: