diff options
author | Adam Tauber <asciimoo@gmail.com> | 2019-12-02 13:39:58 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-02 13:39:58 +0000 |
commit | 731e34299d128f9352fd76e603c960c1f0628ed9 (patch) | |
tree | f591dc036131f2c3a045fbc557f66afc905646cb /searx/engines/doku.py | |
parent | 574cb25a16c3011f1797115cb6c90117e9bd1e8e (diff) | |
parent | 85b37233458c21b775bf98568c0a5c9260aa14fe (diff) | |
download | searxng-731e34299d128f9352fd76e603c960c1f0628ed9.tar.gz searxng-731e34299d128f9352fd76e603c960c1f0628ed9.zip |
Merge pull request #1744 from dalf/optimizations
[mod] speed optimization
Diffstat (limited to 'searx/engines/doku.py')
-rw-r--r-- | searx/engines/doku.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/searx/engines/doku.py b/searx/engines/doku.py index a391be444..d20e66026 100644 --- a/searx/engines/doku.py +++ b/searx/engines/doku.py @@ -11,6 +11,7 @@ from lxml.html import fromstring from searx.engines.xpath import extract_text +from searx.utils import eval_xpath from searx.url_utils import urlencode # engine dependent config @@ -45,16 +46,16 @@ def response(resp): # parse results # Quickhits - for r in doc.xpath('//div[@class="search_quickresult"]/ul/li'): + for r in eval_xpath(doc, '//div[@class="search_quickresult"]/ul/li'): try: - res_url = r.xpath('.//a[@class="wikilink1"]/@href')[-1] + res_url = eval_xpath(r, './/a[@class="wikilink1"]/@href')[-1] except: continue if not res_url: continue - title = extract_text(r.xpath('.//a[@class="wikilink1"]/@title')) + title = extract_text(eval_xpath(r, './/a[@class="wikilink1"]/@title')) # append result results.append({'title': title, @@ -62,13 +63,13 @@ def response(resp): 'url': base_url + res_url}) # Search results - for r in doc.xpath('//dl[@class="search_results"]/*'): + for r in eval_xpath(doc, '//dl[@class="search_results"]/*'): try: if r.tag == "dt": - res_url = r.xpath('.//a[@class="wikilink1"]/@href')[-1] - title = extract_text(r.xpath('.//a[@class="wikilink1"]/@title')) + res_url = eval_xpath(r, './/a[@class="wikilink1"]/@href')[-1] + title = extract_text(eval_xpath(r, './/a[@class="wikilink1"]/@title')) elif r.tag == "dd": - content = extract_text(r.xpath('.')) + content = extract_text(eval_xpath(r, '.')) # append result results.append({'title': title, |