mirror of
https://github.com/searxng/searxng.git
synced 2025-07-24 13:49:26 +02:00
[enh] engine types
This commit is contained in:
parent
c3b7ed8687
commit
d793c2733c
7 changed files with 34 additions and 29 deletions
|
@ -1,14 +1,19 @@
|
|||
from lxml import html
|
||||
from json import loads
|
||||
|
||||
|
||||
def request(query, params):
|
||||
params['method'] = 'POST'
|
||||
params['url'] = 'https://duckduckgo.com/html'
|
||||
params['data']['q'] = query
|
||||
params['url'] = 'https://duckduckgo.com/d.js?q=%s&l=us-en&p=1&s=0' % query
|
||||
return params
|
||||
|
||||
|
||||
def response(resp):
|
||||
dom = html.fromstring(resp.text)
|
||||
results = dom.xpath('//div[@class="results_links results_links_deep web-result"]')
|
||||
return [html.tostring(x) for x in results]
|
||||
results = []
|
||||
search_res = loads(resp.text[resp.text.find('[{'):-2])[:-1]
|
||||
for r in search_res:
|
||||
if not r.get('t'):
|
||||
continue
|
||||
results.append({'title': r['t']
|
||||
,'content': r['a']
|
||||
,'url': r['u']
|
||||
})
|
||||
return results
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue