Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
searx-engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
searx-engine
Commits
50c83686
Commit
50c83686
authored
Aug 05, 2018
by
Alex
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fetch_firefox_version.py : compatible with Python 3 and minor fixes.
parent
066bd916
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
20 deletions
+23
-20
useragents.json
searx/data/useragents.json
+9
-10
utils.py
searx/utils.py
+2
-2
fetch_firefox_version.py
utils/fetch_firefox_version.py
+12
-8
No files found.
searx/data/useragents.json
View file @
50c83686
{
{
"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"
:
[
"os"
:
[
"Windows NT 10; WOW64"
,
"Windows NT 10; WOW64"
,
"X11; Linux x86_64"
"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 file
searx/utils.py
View file @
50c83686
...
@@ -54,8 +54,8 @@ def searx_useragent():
...
@@ -54,8 +54,8 @@ def searx_useragent():
suffix
=
settings
[
'outgoing'
]
.
get
(
'useragent_suffix'
,
''
))
suffix
=
settings
[
'outgoing'
]
.
get
(
'useragent_suffix'
,
''
))
def
gen_useragent
():
def
gen_useragent
(
os
=
None
):
return
str
(
useragents
[
'ua'
]
.
format
(
os
=
choice
(
useragents
[
'os'
]),
version
=
choice
(
useragents
[
'versions'
])))
return
str
(
useragents
[
'ua'
]
.
format
(
os
=
os
or
choice
(
useragents
[
'os'
]),
version
=
choice
(
useragents
[
'versions'
])))
def
highlight_content
(
content
,
query
):
def
highlight_content
(
content
,
query
):
...
...
utils/fetch_firefox_version.py
View file @
50c83686
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
# set path
# set path
from
sys
import
path
from
sys
import
path
from
os.path
import
realpath
,
dirname
from
os.path
import
realpath
,
dirname
,
join
path
.
append
(
realpath
(
dirname
(
realpath
(
__file__
))
+
'/../'
))
path
.
append
(
realpath
(
dirname
(
realpath
(
__file__
))
+
'/../'
))
#
#
...
@@ -12,16 +12,17 @@ import re
...
@@ -12,16 +12,17 @@ import re
from
distutils.version
import
LooseVersion
,
StrictVersion
from
distutils.version
import
LooseVersion
,
StrictVersion
from
lxml
import
html
from
lxml
import
html
from
searx.url_utils
import
urlparse
,
urljoin
from
searx.url_utils
import
urlparse
,
urljoin
from
searx
import
searx_dir
URL
=
'https://ftp.mozilla.org/pub/firefox/releases/'
URL
=
'https://ftp.mozilla.org/pub/firefox/releases/'
RELEASE_PATH
=
'/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]+)$')
# BETA_REGEX = re.compile('.*[0-9]b([0-9\-a-z]+)$')
# ESR_REGEX = re.compile('^[0-9]+\.[0-9](\.[0-9])?esr$')
# ESR_REGEX = re.compile('^[0-9]+\.[0-9](\.[0-9])?esr$')
#
#
useragent
=
{
useragent
s
=
{
"versions"
:
(),
"versions"
:
(),
"os"
:
(
'Windows NT 10; WOW64'
,
"os"
:
(
'Windows NT 10; WOW64'
,
'X11; Linux x86_64'
),
'X11; Linux x86_64'
),
...
@@ -57,13 +58,16 @@ def fetch_firefox_last_versions():
...
@@ -57,13 +58,16 @@ def fetch_firefox_last_versions():
major_list
=
(
major_last
,
major_last
-
1
)
major_list
=
(
major_last
,
major_last
-
1
)
for
version
in
versions
:
for
version
in
versions
:
major_current
=
version
.
version
[
0
]
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
)
result
.
append
(
version
.
vstring
)
return
result
return
result
useragent
[
"versions"
]
=
fetch_firefox_last_versions
()
def
get_useragents_filename
():
f
=
open
(
"../searx/data/useragents.json"
,
"wb"
)
return
join
(
join
(
searx_dir
,
"data"
),
"useragents.json"
)
json
.
dump
(
useragent
,
f
,
sort_keys
=
True
,
indent
=
4
,
ensure_ascii
=
False
,
encoding
=
"utf-8"
)
f
.
close
()
useragents
[
"versions"
]
=
fetch_firefox_last_versions
()
with
open
(
get_useragents_filename
(),
"w"
)
as
f
:
json
.
dump
(
useragents
,
f
,
indent
=
4
,
ensure_ascii
=
False
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment