diff --git a/caotek_mesavoirs/models/actifs.py b/caotek_mesavoirs/models/actifs.py index f4953ad..041d4db 100644 --- a/caotek_mesavoirs/models/actifs.py +++ b/caotek_mesavoirs/models/actifs.py @@ -153,9 +153,9 @@ def getCurrencyRate(currency): rate = divs[1].span.text return float(rate.replace(',','.')) -def getYahooQuote(ticker): - # specify the url - quote_page = 'https://finance.yahoo.com/quote/%s/history/' % ticker +def getFTQuote(ticker): + # specify the url of The Financial Times + quote_page = 'https://markets.ft.com/data/funds/tearsheet/historical?s=%s' % ticker # query & parse the html using beautiful soap and store in variable `soup` soup = BeautifulSoup(urllib2.urlopen(quote_page), 'html.parser') @@ -164,11 +164,10 @@ def getYahooQuote(ticker): rows = soup.findAll('table')[0].tbody.findAll('tr') for each_row in rows: divs = each_row.findAll('td') - if divs[1].span.text != 'Dividend': #Ignore this row in the table - #I'm only interested in 'Close' price; - data.append({'Date': divs[0].span.text, 'Close': float(divs[5].span.text.replace(',',''))}) - break + #I'm only interested in 'Close' price; + quote_price = float(divs[4].text.replace(',','')) + break # retourne la prière ligne - return data[0] + return quote_price diff --git a/caotek_mesavoirs/templates/actifs/actif_edit.pt b/caotek_mesavoirs/templates/actifs/actif_edit.pt index 067ca4b..462c28b 100644 --- a/caotek_mesavoirs/templates/actifs/actif_edit.pt +++ b/caotek_mesavoirs/templates/actifs/actif_edit.pt @@ -21,7 +21,7 @@