diff options
author | Gaspard d'Hautefeuille <github@dhautefeuille.eu> | 2020-07-12 23:43:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-12 23:43:24 +0100 |
commit | 4e346e741a2a3303f2e88fa614e2047ee7ef1089 (patch) | |
tree | 4a4a45ce5751ce742bbc5abed93a66fb0dbbb535 /searx/engines | |
parent | c41db5f1ba9984a916261535a9227fadb897f4bf (diff) | |
download | searxng-4e346e741a2a3303f2e88fa614e2047ee7ef1089.tar.gz searxng-4e346e741a2a3303f2e88fa614e2047ee7ef1089.zip |
fix python 3 support
Diffstat (limited to 'searx/engines')
-rw-r--r-- | searx/engines/translated.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/searx/engines/translated.py b/searx/engines/translated.py index 5c7b17033..6cb18ff39 100644 --- a/searx/engines/translated.py +++ b/searx/engines/translated.py @@ -9,23 +9,19 @@ @parse url, title, content """ import re -from sys import version_info from searx.utils import is_valid_lang -if version_info[0] == 3: - unicode = str - categories = ['general'] -url = u'http://api.mymemory.translated.net/get?q={query}&langpair={from_lang}|{to_lang}{key}' -web_url = u'http://mymemory.translated.net/en/{from_lang}/{to_lang}/{query}' +url = u'https://api.mymemory.translated.net/get?q={query}&langpair={from_lang}|{to_lang}{key}' +web_url = u'https://mymemory.translated.net/en/{from_lang}/{to_lang}/{query}' weight = 100 -parser_re = re.compile(u'.*?([a-z]+)-([a-z]+) (.{2,})$', re.I) +parser_re = re.compile(b'.*?([a-z]+)-([a-z]+) (.{2,})$', re.I) api_key = '' def request(query, params): - m = parser_re.match(unicode(query, 'utf8')) + m = parser_re.match(query) if not m: return params @@ -43,9 +39,9 @@ def request(query, params): key_form = '' params['url'] = url.format(from_lang=from_lang[1], to_lang=to_lang[1], - query=query, + query=query.decode('utf-8'), key=key_form) - params['query'] = query + params['query'] = query.decode('utf-8') params['from_lang'] = from_lang params['to_lang'] = to_lang |