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
0169b63e
Commit
0169b63e
authored
Jan 07, 2019
by
Marc Abonce Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[fix] fetch google's supported languages
parent
51111c25
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18945 additions
and
18697 deletions
+18945
-18697
engines_languages.json
searx/data/engines_languages.json
+18935
-18671
google.py
searx/engines/google.py
+3
-3
test_google.py
tests/unit/engines/test_google.py
+7
-23
No files found.
searx/data/engines_languages.json
View file @
0169b63e
This diff is collapsed.
Click to expand it.
searx/engines/google.py
View file @
0169b63e
...
...
@@ -381,10 +381,10 @@ def attributes_to_html(attributes):
def
_fetch_supported_languages
(
resp
):
supported_languages
=
{}
dom
=
html
.
fromstring
(
resp
.
text
)
options
=
dom
.
xpath
(
'//
table//td/font/label/span
'
)
options
=
dom
.
xpath
(
'//
*[@id="langSec"]//input[@name="lr"]
'
)
for
option
in
options
:
code
=
option
.
xpath
(
'./@
id'
)[
0
][
1
:
]
name
=
option
.
text
.
title
()
code
=
option
.
xpath
(
'./@
value'
)[
0
]
.
split
(
'_'
)[
-
1
]
name
=
option
.
xpath
(
'./@data-name'
)[
0
]
.
title
()
supported_languages
[
code
]
=
{
"name"
:
name
}
return
supported_languages
tests/unit/engines/test_google.py
View file @
0169b63e
...
...
@@ -205,29 +205,13 @@ class TestGoogleEngine(SearxTestCase):
html
=
u"""
<html>
<body>
<table>
<tbody>
<tr>
<td>
<font>
<label>
<span id="ten">English</span>
</label>
</font>
</td>
<td>
<font>
<label>
<span id="tzh-CN">中文 (简体)</span>
</label>
<label>
<span id="tzh-TW">中文 (繁體)</span>
</label>
</font>
</td>
</tr>
</tbody>
</table>
<div id="langSec">
<div>
<input name="lr" data-name="english" value="lang_en" />
<input name="lr" data-name="中文 (简体)" value="lang_zh-CN" />
<input name="lr" data-name="中文 (繁體)" value="lang_zh-TW" />
</div>
</div>
</body>
</html>
"""
...
...
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