replace yahoo currency by FT currency

This commit is contained in:
2018-10-02 08:14:37 +02:00
parent 3b146e7aeb
commit 12f748448b
4 changed files with 11 additions and 10 deletions

View File

@@ -143,15 +143,18 @@ def delete_histo(request, no_id):
def getCurrencyRate(currency):
# specify the url
quote_page = 'http://www.finances.net/devises/courseuro'
quote_page = 'https://markets.ft.com/data/currencies/tearsheet/summary?s=%seur' % currency
# query & parse the html using beautiful soap and store in variable `soup`
soup = BeautifulSoup(urllib2.urlopen(quote_page), 'html.parser')
# get the history table
rows = soup.find('table', attrs={'class': 'news_table'}).tbody.findAll('tr')
divs = rows[1].findAll('td')
rate = divs[1].span.text
return float(rate.replace(',','.'))
data_list = soup.find_all("span", class_="mod-ui-data-list__value")
if data_list:
# get the rate price in EUR
rate_price = float(data_list[0].text.replace(',',''))
else:
rate_price = 0.0
return rate_price
def getFTQuote(ticker):
# specify the url of The Financial Times