diff options
Diffstat (limited to 'searx/engines')
-rw-r--r-- | searx/engines/__init__.py | 15 | ||||
-rw-r--r-- | searx/engines/duckduckgo.py | 14 |
2 files changed, 29 insertions, 0 deletions
diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py new file mode 100644 index 000000000..34d88b749 --- /dev/null +++ b/searx/engines/__init__.py @@ -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)) diff --git a/searx/engines/duckduckgo.py b/searx/engines/duckduckgo.py new file mode 100644 index 000000000..ed93829ba --- /dev/null +++ b/searx/engines/duckduckgo.py @@ -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] |