get quote price from FT
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user