diff options
author | Adam Tauber <asciimoo@gmail.com> | 2016-11-30 18:43:03 +0100 |
---|---|---|
committer | Adam Tauber <asciimoo@gmail.com> | 2017-05-15 12:02:30 +0200 |
commit | 52e615dede8538c36f569d2cf07835427a9a0db6 (patch) | |
tree | ac65990c72156def2d49e81d981f0b3beda4fd2e /searx/engines/wolframalpha_noapi.py | |
parent | 46a2c63f8e1c3819cceff2d61fe9106051e8ecee (diff) | |
download | searxng-52e615dede8538c36f569d2cf07835427a9a0db6.tar.gz searxng-52e615dede8538c36f569d2cf07835427a9a0db6.zip |
[enh] py3 compatibility
Diffstat (limited to 'searx/engines/wolframalpha_noapi.py')
-rw-r--r-- | searx/engines/wolframalpha_noapi.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/searx/engines/wolframalpha_noapi.py b/searx/engines/wolframalpha_noapi.py index 1534501b3..2a8642f92 100644 --- a/searx/engines/wolframalpha_noapi.py +++ b/searx/engines/wolframalpha_noapi.py @@ -10,10 +10,9 @@ from json import loads from time import time -from urllib import urlencode -from lxml.etree import XML from searx.poolrequests import get as http_get +from searx.url_utils import urlencode # search-url url = 'https://www.wolframalpha.com/' @@ -62,7 +61,7 @@ obtain_token() # do search-request def request(query, params): # obtain token if last update was more than an hour - if time() - token['last_updated'] > 3600: + if time() - (token['last_updated'] or 0) > 3600: obtain_token() params['url'] = search_url.format(query=urlencode({'input': query}), token=token['value']) params['headers']['Referer'] = referer_url.format(query=urlencode({'i': query})) @@ -112,9 +111,9 @@ def response(resp): results.append({'infobox': infobox_title, 'attributes': result_chunks, - 'urls': [{'title': 'Wolfram|Alpha', 'url': resp.request.headers['Referer'].decode('utf8')}]}) + 'urls': [{'title': 'Wolfram|Alpha', 'url': resp.request.headers['Referer']}]}) - results.append({'url': resp.request.headers['Referer'].decode('utf8'), + results.append({'url': resp.request.headers['Referer'], 'title': 'Wolfram|Alpha (' + infobox_title + ')', 'content': result_content}) |