[enh] add re-usable func to filter text

This commit is contained in:
Allen 2024-05-23 23:21:58 +00:00 committed by Markus Heiser
parent 0fb3f0e4ae
commit 0fa81fc782
6 changed files with 53 additions and 25 deletions

View file

@ -7,6 +7,8 @@ from urllib.parse import urlencode
from json import loads
from dateutil import parser
from searx.utils import extr
# about
about = {
"website": 'https://vimeo.com/',
@ -23,7 +25,7 @@ paging = True
# search-url
base_url = 'https://vimeo.com/'
search_url = base_url + '/search/page:{pageno}?{query}'
search_url = base_url + 'search/page:{pageno}?{query}'
# do search-request
@ -36,9 +38,8 @@ def request(query, params):
# get response from search-request
def response(resp):
results = []
data_start_pos = resp.text.find('{"filtered"')
data_end_pos = resp.text.find(';\n', data_start_pos + 1)
data = loads(resp.text[data_start_pos:data_end_pos])
data = loads(extr(resp.text, 'var data = ', ';\n'))
# parse results
for result in data['filtered']['data']: