on master help sign in
[fix] compile regex in ddg_definitions
commita44faa77167980a414df2cbe936a52359351f455 authora01200356 <a01200356@itesm.mx> dateMon 18 Apr 2016, 10:52 (10 years ago) parent6dca14e
1 file changed+4−2
searx/engines/duckduckgo_definitions.py+4−2
searx/engines/duckduckgo_definitions.py+4−2
@@ -1,6 +1,6 @@
11import json
22from urllib import urlencode
3−from re import sub
3+from re import compile, sub
44from lxml import html
55from searx.utils import html_to_text
66from searx.engines.xpath import extract_text
@@ -8,6 +8,8 @@ from searx.engines.xpath import extract_text
88url = 'https://api.duckduckgo.com/'\
99 + '?{query}&format=json&pretty=0&no_redirect=1&d=1'
1010
11+http_regex = compile(r'^http:')
12+
1113
1214def result_to_text(url, text, htmlResult):
1315 # TODO : remove result ending with "Meaning" or "Category"
@@ -106,7 +108,7 @@ def response(resp):
106108
107109 # to merge with wikidata's infobox
108110 if infobox_id:
109− infobox_id = sub(r'^http:', r'https:', infobox_id)
111+ infobox_id = http_regex.sub('https:', infobox_id)
110112
111113 # entity
112114 entity = search_res.get('Entity', None)