mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
Drop Python 2 (4/n): SearchQuery.query is a str instead of bytes
This commit is contained in:
parent
7888377743
commit
c225db45c8
20 changed files with 48 additions and 48 deletions
|
|
@ -105,7 +105,7 @@ def request(query, params):
|
|||
# if our language is hosted on the main site, we need to add its name
|
||||
# to the query in order to narrow the results to that language
|
||||
if language in main_langs:
|
||||
query += b' (' + main_langs[language] + b')'
|
||||
query += ' (' + main_langs[language] + ')'
|
||||
|
||||
# prepare the request parameters
|
||||
query = urlencode({'search': query})
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ def request(query, params):
|
|||
# basic search
|
||||
offset = (params['pageno'] - 1) * number_of_results
|
||||
|
||||
string_args = dict(query=query.decode(),
|
||||
string_args = dict(query=query,
|
||||
offset=offset,
|
||||
number_of_results=number_of_results)
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ shorcut_dict = {
|
|||
def request(query, params):
|
||||
# replace shortcuts with API advanced search keywords
|
||||
for key in shorcut_dict.keys():
|
||||
query = re.sub(key, shorcut_dict[key], str(query))
|
||||
query = re.sub(key, shorcut_dict[key], query)
|
||||
|
||||
# basic search
|
||||
offset = (params['pageno'] - 1) * number_of_results
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ def request(query, params):
|
|||
else:
|
||||
lang = match_language(params['language'], supported_languages, language_aliases)
|
||||
|
||||
query = 'language:{} {}'.format(lang.split('-')[0].upper(), query.decode()).encode()
|
||||
query = 'language:{} {}'.format(lang.split('-')[0].upper(), query)
|
||||
|
||||
search_path = search_string.format(
|
||||
query=urlencode({'q': query}),
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@ categories = []
|
|||
url = 'https://duckduckgo.com/js/spice/currency/1/{0}/{1}'
|
||||
weight = 100
|
||||
|
||||
parser_re = re.compile(b'.*?(\\d+(?:\\.\\d+)?) ([^.0-9]+) (?:in|to) ([^.0-9]+)', re.I)
|
||||
parser_re = re.compile('.*?(\\d+(?:\\.\\d+)?) ([^.0-9]+) (?:in|to) ([^.0-9]+)', re.I)
|
||||
|
||||
db = 1
|
||||
|
||||
|
||||
def normalize_name(name):
|
||||
name = name.decode().lower().replace('-', ' ').rstrip('s')
|
||||
name = name.lower().replace('-', ' ').rstrip('s')
|
||||
name = re.sub(' +', ' ', name)
|
||||
return unicodedata.normalize('NFKD', name).lower()
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ categories = ['general']
|
|||
url = 'https://dictzone.com/{from_lang}-{to_lang}-dictionary/{query}'
|
||||
weight = 100
|
||||
|
||||
parser_re = re.compile(b'.*?([a-z]+)-([a-z]+) ([^ ]+)$', re.I)
|
||||
parser_re = re.compile('.*?([a-z]+)-([a-z]+) ([^ ]+)$', re.I)
|
||||
results_xpath = './/table[@id="r"]/tr'
|
||||
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ def request(query, params):
|
|||
|
||||
params['url'] = url.format(from_lang=from_lang[2],
|
||||
to_lang=to_lang[2],
|
||||
query=query.decode())
|
||||
query=query)
|
||||
|
||||
return params
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ def request(query, params):
|
|||
# if our language is hosted on the main site, we need to add its name
|
||||
# to the query in order to narrow the results to that language
|
||||
if language in main_langs:
|
||||
query += b' (' + (main_langs[language]).encode() + b')'
|
||||
query += ' (' + main_langs[language] + ')'
|
||||
|
||||
# prepare the request parameters
|
||||
query = urlencode({'search': query})
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ route_re = re.compile('(?:from )?(.+) to (.+)')
|
|||
# do search-request
|
||||
def request(query, params):
|
||||
|
||||
params['url'] = base_url + search_string.format(query=query.decode())
|
||||
params['route'] = route_re.match(query.decode())
|
||||
params['url'] = base_url + search_string.format(query=query)
|
||||
params['route'] = route_re.match(query)
|
||||
|
||||
return params
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ def request(query, params):
|
|||
params['url'] = search_url
|
||||
params['method'] = 'POST'
|
||||
params['headers']['Content-type'] = "application/json"
|
||||
params['data'] = dumps({"query": query.decode(),
|
||||
params['data'] = dumps({"query": query,
|
||||
"searchField": "ALL",
|
||||
"sortDirection": "ASC",
|
||||
"sortOrder": "RELEVANCY",
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ url = 'https://api.mymemory.translated.net/get?q={query}&langpair={from_lang}|{t
|
|||
web_url = 'https://mymemory.translated.net/en/{from_lang}/{to_lang}/{query}'
|
||||
weight = 100
|
||||
|
||||
parser_re = re.compile(b'.*?([a-z]+)-([a-z]+) (.{2,})$', re.I)
|
||||
parser_re = re.compile('.*?([a-z]+)-([a-z]+) (.{2,})$', re.I)
|
||||
api_key = ''
|
||||
|
||||
|
||||
|
|
@ -39,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.decode(),
|
||||
query=query,
|
||||
key=key_form)
|
||||
params['query'] = query.decode()
|
||||
params['query'] = query
|
||||
params['from_lang'] = from_lang
|
||||
params['to_lang'] = to_lang
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue