|
@@ -1,6 +1,7 @@
|
1
|
1
|
import json
|
2
|
2
|
from urllib import urlencode
|
3
|
3
|
from lxml import html
|
|
4
|
+from searx.utils import html_to_text
|
4
|
5
|
from searx.engines.xpath import extract_text
|
5
|
6
|
|
6
|
7
|
url = 'https://api.duckduckgo.com/'\
|
|
@@ -17,11 +18,6 @@ def result_to_text(url, text, htmlResult):
|
17
|
18
|
return text
|
18
|
19
|
|
19
|
20
|
|
20
|
|
-def html_to_text(htmlFragment):
|
21
|
|
- dom = html.fromstring(htmlFragment)
|
22
|
|
- return extract_text(dom)
|
23
|
|
-
|
24
|
|
-
|
25
|
21
|
def request(query, params):
|
26
|
22
|
# TODO add kl={locale}
|
27
|
23
|
params['url'] = url.format(query=urlencode({'q': query}))
|