forked from Archives/searxng
[enh] engine types
parent
c3b7ed8687
commit
d793c2733c
@ -1,7 +0,0 @@
|
||||
|
||||
base_result_template = """
|
||||
<div class="result">
|
||||
<h3 class="result_title"><a href="{url}">{title}</a></h3>
|
||||
<p class="content">{content}<br />{url}</p>
|
||||
</div>
|
||||
"""
|
@ -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…
Reference in New Issue