瀏覽代碼

[fix] currency converter - valid date url param

asciimoo 11 年之前
父節點
當前提交
1240be48fb
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8
    1
      searx/engines/currency_convert.py

+ 8
- 1
searx/engines/currency_convert.py 查看文件

@@ -1,3 +1,4 @@
1
+from datetime import datetime
1 2
 
2 3
 categories = []
3 4
 url = 'http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s={query}=X'
@@ -40,7 +41,13 @@ def response(resp):
40 41
                                           )
41 42
 
42 43
     content = '1 {0} is {1} {2}'.format(resp.search_params['from'], conversion_rate, resp.search_params['to'])
43
-    url = 'http://finance.yahoo.com/currency/converter-results/20131104/{0}-{1}-to-{2}.html'.format(resp.search_params['ammount'], resp.search_params['from'].lower(), resp.search_params['to'].lower())
44
+    now_date = datetime.now().strftime('%Y%m%d')
45
+    url = 'http://finance.yahoo.com/currency/converter-results/{0}/{1}-{2}-to-{3}.html'
46
+    url = url.format(now_date
47
+                    ,resp.search_params['ammount']
48
+                    ,resp.search_params['from'].lower()
49
+                    ,resp.search_params['to'].lower()
50
+                    )
44 51
     results.append({'title': title, 'content': content, 'url': url})
45 52
 
46 53
     return results