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
2231b02a
Commit
2231b02a
authored
Nov 07, 2017
by
pyrrh0n1c
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed the currency_convert engine.
parent
00a7041d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
11 deletions
+8
-11
currency_convert.py
searx/engines/currency_convert.py
+8
-11
No files found.
searx/engines/currency_convert.py
View file @
2231b02a
...
...
@@ -10,7 +10,7 @@ if sys.version_info[0] == 3:
unicode
=
str
categories
=
[]
url
=
'https://
download.finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s={query}=X
'
url
=
'https://
finance.google.com/finance/converter?a=1&from={0}&to={1}
'
weight
=
100
parser_re
=
re
.
compile
(
b
'.*?(
\\
d+(?:
\\
.
\\
d+)?) ([^.0-9]+) (?:in|to) ([^.0-9]+)'
,
re
.
I
)
...
...
@@ -51,7 +51,7 @@ def request(query, params):
q
=
(
from_currency
+
to_currency
)
.
upper
()
params
[
'url'
]
=
url
.
format
(
query
=
q
)
params
[
'url'
]
=
url
.
format
(
from_currency
,
to_currency
)
params
[
'ammount'
]
=
ammount
params
[
'from'
]
=
from_currency
params
[
'to'
]
=
to_currency
...
...
@@ -63,8 +63,11 @@ def request(query, params):
def
response
(
resp
):
results
=
[]
pat
=
'<span class=bld>(.+) {0}</span>'
.
format
(
resp
.
search_params
[
'to'
]
.
upper
())
try
:
_
,
conversion_rate
,
_
=
resp
.
text
.
split
(
','
,
2
)
conversion_rate
=
re
.
findall
(
pat
,
resp
.
text
)[
0
]
conversion_rate
=
float
(
conversion_rate
)
except
:
return
results
...
...
@@ -79,14 +82,8 @@ def response(resp):
resp
.
search_params
[
'to_name'
],
)
now_date
=
datetime
.
now
()
.
strftime
(
'
%
Y
%
m
%
d'
)
url
=
'https://finance.yahoo.com/currency/converter-results/{0}/{1}-{2}-to-{3}.html'
# noqa
url
=
url
.
format
(
now_date
,
resp
.
search_params
[
'ammount'
],
resp
.
search_params
[
'from'
]
.
lower
(),
resp
.
search_params
[
'to'
]
.
lower
()
)
url
=
'https://finance.google.com/finance?q={0}{1}'
.
format
(
resp
.
search_params
[
'from'
]
.
upper
(),
resp
.
search_params
[
'to'
])
results
.
append
({
'answer'
:
answer
,
'url'
:
url
})
...
...
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