mirror of
https://github.com/searxng/searxng.git
synced 2025-08-03 02:22:22 +02:00
[enh] initial commit
This commit is contained in:
commit
ae9fb1d7dc
11 changed files with 139 additions and 0 deletions
15
searx/engines/__init__.py
Normal file
15
searx/engines/__init__.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
|
||||
from os.path import realpath, dirname, splitext, join
|
||||
from os import listdir
|
||||
from imp import load_source
|
||||
|
||||
engine_dir = dirname(realpath(__file__))
|
||||
|
||||
engines = []
|
||||
|
||||
for filename in listdir(engine_dir):
|
||||
modname = splitext(filename)[0]
|
||||
if filename.startswith('_') or not filename.endswith('.py'):
|
||||
continue
|
||||
filepath = join(engine_dir, filename)
|
||||
engines.append(load_source(modname, filepath))
|
14
searx/engines/duckduckgo.py
Normal file
14
searx/engines/duckduckgo.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
from lxml import html
|
||||
|
||||
|
||||
def request(query, params):
|
||||
params['method'] = 'POST'
|
||||
params['url'] = 'https://duckduckgo.com/html'
|
||||
params['data']['q'] = 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]
|
Loading…
Add table
Add a link
Reference in a new issue