mirror of
https://github.com/searxng/searxng.git
synced 2025-08-28 22:36:54 +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 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']:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue