mirror of
https://github.com/searxng/searxng.git
synced 2025-12-23 04:00:02 +00:00
[enh] add re-usable func to filter text
This commit is contained in:
@@ -7,6 +7,8 @@ from functools import reduce
|
||||
from json import loads, dumps
|
||||
from urllib.parse import quote_plus
|
||||
|
||||
from searx.utils import extr
|
||||
|
||||
# about
|
||||
about = {
|
||||
"website": 'https://www.youtube.com/',
|
||||
@@ -109,8 +111,8 @@ def parse_next_page_response(response_text):
|
||||
|
||||
def parse_first_page_response(response_text):
|
||||
results = []
|
||||
results_data = response_text[response_text.find('ytInitialData') :]
|
||||
results_data = results_data[results_data.find('{') : results_data.find(';</script>')]
|
||||
results_data = extr(response_text, 'ytInitialData = ', ';</script>')
|
||||
|
||||
results_json = loads(results_data) if results_data else {}
|
||||
sections = (
|
||||
results_json.get('contents', {})
|
||||
|
||||
Reference in New Issue
Block a user