diff options
author | a01200356 <a01200356@itesm.mx> | 2016-04-18 10:52:16 -0500 |
---|---|---|
committer | a01200356 <a01200356@itesm.mx> | 2016-04-19 12:46:15 -0500 |
commit | a44faa77167980a414df2cbe936a52359351f455 (patch) | |
tree | 1a136070c8acd73449ba6e0a4d74b52ed8b0bce6 /searx/engines/duckduckgo_definitions.py | |
parent | 6dca14e95d08479fb49314cb4093be36ac49cf94 (diff) | |
download | searxng-a44faa77167980a414df2cbe936a52359351f455.tar.gz searxng-a44faa77167980a414df2cbe936a52359351f455.zip |
[fix] compile regex in ddg_definitions
Diffstat (limited to 'searx/engines/duckduckgo_definitions.py')
-rw-r--r-- | searx/engines/duckduckgo_definitions.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/searx/engines/duckduckgo_definitions.py b/searx/engines/duckduckgo_definitions.py index dc25d416f..208ccca28 100644 --- a/searx/engines/duckduckgo_definitions.py +++ b/searx/engines/duckduckgo_definitions.py @@ -1,6 +1,6 @@ import json from urllib import urlencode -from re import sub +from re import compile, sub from lxml import html from searx.utils import html_to_text from searx.engines.xpath import extract_text @@ -8,6 +8,8 @@ from searx.engines.xpath import extract_text url = 'https://api.duckduckgo.com/'\ + '?{query}&format=json&pretty=0&no_redirect=1&d=1' +http_regex = compile(r'^http:') + def result_to_text(url, text, htmlResult): # TODO : remove result ending with "Meaning" or "Category" @@ -106,7 +108,7 @@ def response(resp): # to merge with wikidata's infobox if infobox_id: - infobox_id = sub(r'^http:', r'https:', infobox_id) + infobox_id = http_regex.sub('https:', infobox_id) # entity entity = search_res.get('Entity', None) |