diff options
| author | Dalf <alex@al-f.net> | 2019-11-15 09:31:37 +0100 |
|---|---|---|
| committer | Dalf <alex@al-f.net> | 2019-11-15 09:33:15 +0100 |
| commit | 85b37233458c21b775bf98568c0a5c9260aa14fe (patch) | |
| tree | 4b79330d170d3f8dbc0c52dadbfef429c31b2187 /searx/engines/gigablast.py | |
| parent | 42d5e2c02cd4715a0e09411efbb249ef5d8defed (diff) | |
[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/gigablast.py')
| -rw-r--r-- | searx/engines/gigablast.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/searx/engines/gigablast.py b/searx/engines/gigablast.py index 6b0402233..a84f3f69d 100644 --- a/searx/engines/gigablast.py +++ b/searx/engines/gigablast.py @@ -15,6 +15,7 @@ from json import loads from time import time from lxml.html import fromstring from searx.url_utils import urlencode +from searx.utils import eval_xpath # engine dependent config categories = ['general'] @@ -99,9 +100,9 @@ def response(resp): def _fetch_supported_languages(resp): supported_languages = [] dom = fromstring(resp.text) - links = dom.xpath('//span[@id="menu2"]/a') + links = eval_xpath(dom, '//span[@id="menu2"]/a') for link in links: - href = link.xpath('./@href')[0].split('lang%3A') + href = eval_xpath(link, './@href')[0].split('lang%3A') if len(href) == 2: code = href[1].split('_') if len(code) == 2: |