ソースを参照

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

Maxqia 9 年 前
コミット
fe2ce83e41
共有1 個のファイルを変更した2 個の追加2 個の削除を含む
  1. 2
    2
      searx/engines/currency_convert.py

+ 2
- 2
searx/engines/currency_convert.py ファイルの表示

9
 url = 'https://download.finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s={query}=X'
9
 url = 'https://download.finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s={query}=X'
10
 weight = 100
10
 weight = 100
11
 
11
 
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
13
 
13
 
14
 db = 1
14
 db = 1
15
 
15
 
40
         # wrong query
40
         # wrong query
41
         return params
41
         return params
42
 
42
 
43
-    ammount, from_currency, to_currency = m.groups()
43
+    ammount, from_currency, none, to_currency = m.groups()
44
     ammount = float(ammount)
44
     ammount = float(ammount)
45
     from_currency = name_to_iso4217(from_currency.strip())
45
     from_currency = name_to_iso4217(from_currency.strip())
46
     to_currency = name_to_iso4217(to_currency.strip())
46
     to_currency = name_to_iso4217(to_currency.strip())