diff options
| author | Markus Heiser <markus.heiser@darmarIT.de> | 2019-12-24 13:33:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-24 13:33:07 +0100 |
| commit | fb668e2075484084a1f7a9b205ecbe7957ea5e8e (patch) | |
| tree | c6f2e83d9d222d69d79348faac342c07c32dbbf3 /searx/engines/wikidata.py | |
| parent | f407dd8ef4e3f6c82bef31f678139d6db2a4d810 (diff) | |
| parent | 6d232e9b695c2553b7594efe00c4f63aa96fc62d (diff) | |
Merge branch 'master' into libgen
Diffstat (limited to 'searx/engines/wikidata.py')
| -rw-r--r-- | searx/engines/wikidata.py | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/searx/engines/wikidata.py b/searx/engines/wikidata.py index 5ea2b9958..e913b3915 100644 --- a/searx/engines/wikidata.py +++ b/searx/engines/wikidata.py @@ -16,7 +16,7 @@ from searx.poolrequests import get from searx.engines.xpath import extract_text from searx.engines.wikipedia import _fetch_supported_languages, supported_languages_url from searx.url_utils import urlencode -from searx.utils import match_language +from searx.utils import match_language, eval_xpath from json import loads from lxml.html import fromstring @@ -57,22 +57,6 @@ language_fallback_xpath = '//sup[contains(@class,"wb-language-fallback-indicator calendar_name_xpath = './/sup[contains(@class,"wb-calendar-name")]' media_xpath = value_xpath + '//div[contains(@class,"commons-media-caption")]//a' -# xpath_cache -xpath_cache = {} - - -def get_xpath(xpath_str): - result = xpath_cache.get(xpath_str, None) - if not result: - result = etree.XPath(xpath_str) - xpath_cache[xpath_str] = result - return result - - -def eval_xpath(element, xpath_str): - xpath = get_xpath(xpath_str) - return xpath(element) - def get_id_cache(result): id_cache = {} |