From d02ecb4b173126b565cea56b73859fc3c1d07994 Mon Sep 17 00:00:00 2001 From: Phuoc CAO Date: Mon, 1 Oct 2018 11:08:28 +0200 Subject: [PATCH] get data list from quote header --- caotek_mesavoirs/models/actifs.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/caotek_mesavoirs/models/actifs.py b/caotek_mesavoirs/models/actifs.py index 041d4db..3fbc32b 100644 --- a/caotek_mesavoirs/models/actifs.py +++ b/caotek_mesavoirs/models/actifs.py @@ -159,15 +159,12 @@ def getFTQuote(ticker): # query & parse the html using beautiful soap and store in variable `soup` soup = BeautifulSoup(urllib2.urlopen(quote_page), 'html.parser') - data = [] - # get the quote price - rows = soup.findAll('table')[0].tbody.findAll('tr') - for each_row in rows: - divs = each_row.findAll('td') - #I'm only interested in 'Close' price; - quote_price = float(divs[4].text.replace(',','')) - break - - # retourne la prière ligne + data-list = soup.find_all("span", class_="mod-ui-data-list__value") + if data-list: + # get the quote price + quote_price = float(data-list[0].text.replace(',','')) + else: + quote_price = 0.0 + return quote_price