5from os.path import realpath, dirname, join
6path.append(realpath(dirname(realpath(__file__)) + '/../'))
12from distutils.version import LooseVersion, StrictVersion
14from searx.url_utils import urlparse, urljoin
15from searx import searx_dir
17URL = 'https://ftp.mozilla.org/pub/firefox/releases/'
18RELEASE_PATH = '/pub/firefox/releases/'
20NORMAL_REGEX = re.compile('^[0-9]+\.[0-9](\.[0-9])?$')
21# BETA_REGEX = re.compile('.*[0-9]b([0-9\-a-z]+)$')
22# ESR_REGEX = re.compile('^[0-9]+\.[0-9](\.[0-9])?esr$')
27 "os": ('Windows NT 10; WOW64',
29 "ua": "Mozilla/5.0 ({os}; rv:{version}) Gecko/20100101 Firefox/{version}"
33def fetch_firefox_versions():
34 resp = requests.get(URL, timeout=2.0)
35 if resp.status_code != 200:
36 raise Exception("Error fetching firefox versions, HTTP code " + resp.status_code)
38 dom = html.fromstring(resp.text)
41 for link in dom.xpath('//a/@href'):
42 url = urlparse(urljoin(URL, link))
44 if path.startswith(RELEASE_PATH):
45 version = path[len(RELEASE_PATH):-1]
46 if NORMAL_REGEX.match(version):
47 versions.append(LooseVersion(version))
49 list.sort(versions, reverse=True)
53def fetch_firefox_last_versions():
54 versions = fetch_firefox_versions()
57 major_last = versions[0].version[0]
58 major_list = (major_last, major_last - 1)
59 for version in versions:
60 major_current = version.version[0]
61 if major_current in major_list:
62 result.append(version.vstring)
67def get_useragents_filename():
68 return join(join(searx_dir, "data"), "useragents.json")
71useragents["versions"] = fetch_firefox_last_versions()
72with open(get_useragents_filename(), "w") as f:
73 json.dump(useragents, f, indent=4, ensure_ascii=False)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list