summaryrefslogtreecommitdiff
path: root/searx/engines/dictzone.py
diff options
context:
space:
mode:
authorDalf <alex@al-f.net>2019-11-15 09:31:37 +0100
committerDalf <alex@al-f.net>2019-11-15 09:33:15 +0100
commit85b37233458c21b775bf98568c0a5c9260aa14fe (patch)
tree4b79330d170d3f8dbc0c52dadbfef429c31b2187 /searx/engines/dictzone.py
parent42d5e2c02cd4715a0e09411efbb249ef5d8defed (diff)
downloadsearxng-85b37233458c21b775bf98568c0a5c9260aa14fe.tar.gz
searxng-85b37233458c21b775bf98568c0a5c9260aa14fe.zip
[mod] speed optimization
compile XPath only once avoid redundant call to urlparse get_locale(webapp.py): avoid useless call to request.accept_languages.best_match
Diffstat (limited to 'searx/engines/dictzone.py')
-rw-r--r--searx/engines/dictzone.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/searx/engines/dictzone.py b/searx/engines/dictzone.py
index 09db048cc..423af0971 100644
--- a/searx/engines/dictzone.py
+++ b/searx/engines/dictzone.py
@@ -11,7 +11,7 @@
import re
from lxml import html
-from searx.utils import is_valid_lang
+from searx.utils import is_valid_lang, eval_xpath
from searx.url_utils import urljoin
categories = ['general']
@@ -47,14 +47,14 @@ def response(resp):
dom = html.fromstring(resp.text)
- for k, result in enumerate(dom.xpath(results_xpath)[1:]):
+ for k, result in enumerate(eval_xpath(dom, results_xpath)[1:]):
try:
- from_result, to_results_raw = result.xpath('./td')
+ from_result, to_results_raw = eval_xpath(result, './td')
except:
continue
to_results = []
- for to_result in to_results_raw.xpath('./p/a'):
+ for to_result in eval_xpath(to_results_raw, './p/a'):
t = to_result.text_content()
if t.strip():
to_results.append(to_result.text_content())