remplacer le site FT par YAHOO finance

This commit is contained in:
2019-09-29 11:25:48 +02:00
parent b00a7674d3
commit 63a73b6e81
8 changed files with 56 additions and 64 deletions

View File

@@ -10,7 +10,6 @@ from zope.sqlalchemy import ZopeTransactionExtension, mark_changed
from datetime import *
import transaction
from bs4 import BeautifulSoup
from urllib.request import urlopen
from .default import (
@@ -141,33 +140,5 @@ def delete_histo(request, no_id):
query = "DELETE FROM histo WHERE no_id = :no_id ;"
execute_query(request, query, {'no_id': no_id})
def getCurrencyRate(currency):
# specify the url
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(urlopen(quote_page), 'html.parser')
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
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(urlopen(quote_page), 'html.parser')
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