summaryrefslogtreecommitdiff
path: root/searx/engines/startpage.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/startpage.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/startpage.py')
-rw-r--r--searx/engines/startpage.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/searx/engines/startpage.py b/searx/engines/startpage.py
index 0f0ec6e18..76567396f 100644
--- a/searx/engines/startpage.py
+++ b/searx/engines/startpage.py
@@ -16,6 +16,7 @@ from datetime import datetime, timedelta
import re
from searx.engines.xpath import extract_text
from searx.languages import language_codes
+from searx.utils import eval_xpath
# engine dependent config
categories = ['general']
@@ -70,8 +71,8 @@ def response(resp):
dom = html.fromstring(resp.text)
# parse results
- for result in dom.xpath(results_xpath):
- links = result.xpath(link_xpath)
+ for result in eval_xpath(dom, results_xpath):
+ links = eval_xpath(result, link_xpath)
if not links:
continue
link = links[0]
@@ -87,8 +88,8 @@ def response(resp):
title = extract_text(link)
- if result.xpath(content_xpath):
- content = extract_text(result.xpath(content_xpath))
+ if eval_xpath(result, content_xpath):
+ content = extract_text(eval_xpath(result, content_xpath))
else:
content = ''