on master help sign in
Merge pull request #550 from Maxqia/convert

[enh] currency_convert: allow strings like google's "convert 1 euro to dollars"

commitdcc8f996d429e3467f9dab27ed072737e919c2e8 authorAdam Tauber <asciimoo@gmail.com> dateMon 2 May 2016, 09:56 (10 years ago) parent3c6a540fe2ce83
1 file changed+2−2
searx/engines/currency_convert.py+2−2
searx/engines/currency_convert.py+2−2
@@ -9,7 +9,7 @@ categories = []
99url = 'https://download.finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s={query}=X'
1010weight = 100
1111
12−parser_re = re.compile(u'^\W*(\d+(?:\.\d+)?)\W*([^.0-9].+)\W+in?\W+([^\.]+)\W*$', re.I) # noqa
12+parser_re = re.compile(u'.*?(\d+(?:\.\d+)?) ([^.0-9].+) (in|to) ([^\.]+)\W*$', re.I) # noqa
1313
1414db = 1
1515
@@ -40,7 +40,7 @@ def request(query, params):
4040 # wrong query
4141 return params
4242
43− ammount, from_currency, to_currency = m.groups()
43+ ammount, from_currency, none, to_currency = m.groups()
4444 ammount = float(ammount)
4545 from_currency = name_to_iso4217(from_currency.strip())
4646 to_currency = name_to_iso4217(to_currency.strip())