SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
Python bingbravedegoogleduckduckgogooglemetasearchprivacypythonqwantsearchsearch-enginesearxsearxngstartpageyahoo
fetch_firefox_version.py : compatible with Python 3 and minor fixes.
Alex50c836864a9a
diff --git a/searx/data/useragents.json b/searx/data/useragents.jsonindex ba80ce885..850bc418a 100644--- a/searx/data/useragents.json+++ b/searx/data/useragents.json@@ -1,15 +1,14 @@{+ "ua": "Mozilla/5.0 ({os}; rv:{version}) Gecko/20100101 Firefox/{version}",+ "versions": [+ "61.0.1",+ "61.0",+ "60.0.2",+ "60.0.1",+ "60.0"+ ],"os": [- "Windows NT 10; WOW64",+ "Windows NT 10; WOW64","X11; Linux x86_64"- ],- "ua": "Mozilla/5.0 ({os}; rv:{version}) Gecko/20100101 Firefox/{version}",- "versions": [- "59.0.2",- "59.0.1",- "59.0",- "58.0.2",- "58.0.1",- "58.0"]}\ No newline at end of filediff --git a/searx/utils.py b/searx/utils.pyindex f457284e3..dfa22c5fc 100644--- a/searx/utils.py+++ b/searx/utils.py@@ -54,8 +54,8 @@ def searx_useragent():suffix=settings['outgoing'].get('useragent_suffix', ''))-def gen_useragent():- return str(useragents['ua'].format(os=choice(useragents['os']), version=choice(useragents['versions'])))+def gen_useragent(os=None):+ return str(useragents['ua'].format(os=os or choice(useragents['os']), version=choice(useragents['versions'])))def highlight_content(content, query):diff --git a/utils/fetch_firefox_version.py b/utils/fetch_firefox_version.pyindex 21d6e82ff..ed179585b 100755--- a/utils/fetch_firefox_version.py+++ b/utils/fetch_firefox_version.py@@ -2,7 +2,7 @@# set pathfrom sys import path-from os.path import realpath, dirname+from os.path import realpath, dirname, joinpath.append(realpath(dirname(realpath(__file__)) + '/../'))#@@ -12,16 +12,17 @@ import refrom distutils.version import LooseVersion, StrictVersionfrom lxml import htmlfrom searx.url_utils import urlparse, urljoin+from searx import searx_dirURL = 'https://ftp.mozilla.org/pub/firefox/releases/'RELEASE_PATH = '/pub/firefox/releases/'-NORMAL_REGEX = re.compile('^[0-9]+\.[0-9](\.[0-9])?(esr)?$')+NORMAL_REGEX = re.compile('^[0-9]+\.[0-9](\.[0-9])?$')# BETA_REGEX = re.compile('.*[0-9]b([0-9\-a-z]+)$')# ESR_REGEX = re.compile('^[0-9]+\.[0-9](\.[0-9])?esr$')#-useragent = {+useragents = {"versions": (),"os": ('Windows NT 10; WOW64','X11; Linux x86_64'),@@ -57,13 +58,16 @@ def fetch_firefox_last_versions():major_list = (major_last, major_last - 1)for version in versions:major_current = version.version[0]- if major_current in major_list and 'esr' not in version.version:+ if major_current in major_list:result.append(version.vstring)return result-useragent["versions"] = fetch_firefox_last_versions()-f = open("../searx/data/useragents.json", "wb")-json.dump(useragent, f, sort_keys=True, indent=4, ensure_ascii=False, encoding="utf-8")-f.close()+def get_useragents_filename():+ return join(join(searx_dir, "data"), "useragents.json")+++useragents["versions"] = fetch_firefox_last_versions()+with open(get_useragents_filename(), "w") as f:+ json.dump(useragents, f, indent=4, ensure_ascii=False)