mirror of
https://github.com/searxng/searxng.git
synced 2025-07-23 13:19:17 +02:00
[enh] add re-usable func to filter text
This commit is contained in:
parent
0fb3f0e4ae
commit
0fa81fc782
6 changed files with 53 additions and 25 deletions
|
@ -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', {})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue