SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
Python bingbravedegoogleduckduckgogooglemetasearchprivacypythonqwantsearchsearch-enginesearxsearxngstartpageyahoo
[enh] smarter currency query parse
asciimooa35128f5e0af
diff --git a/searx/engines/currency_convert.py b/searx/engines/currency_convert.pyindex c6a4f29ca..b8ba7707f 100644--- a/searx/engines/currency_convert.py+++ b/searx/engines/currency_convert.py@@ -1,21 +1,25 @@from datetime import datetime+import recategories = []url = 'http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s={query}=X'weight = 100+parser_re = re.compile(r'^\W*(\d+(?:\.\d+)?)\W*([a-z]{3})\W*(?:in)?\W*([a-z]{3})\W*$')+def request(query, params):+ m = parser_re.match(query)+ if not m:+ # wrong query+ return paramstry:- # eg.: "X EUR in USD"- ammount, from_currency, _, to_currency = query.split()+ ammount, from_currency, to_currency = m.groups()ammount = float(ammount)except:# wrong paramsreturn paramsq = (from_currency+to_currency).upper()- if not q.isalpha():- return paramsparams['url'] = url.format(query=q)params['ammount'] = ammount