fusionner actifs_list avec home.pt et le supprimer

This commit is contained in:
2018-07-19 18:31:14 +02:00
parent ac6a987f9c
commit 96975673ce
9 changed files with 118 additions and 196 deletions

View File

@@ -10,6 +10,8 @@ from zope.sqlalchemy import ZopeTransactionExtension, mark_changed
from datetime import *
import transaction
from bs4 import BeautifulSoup
import urllib2
from .default import (
execute_query,
@@ -139,3 +141,34 @@ 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 = 'http://www.finances.net/devises/courseuro'
# 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(',','.'))
def getYahooQuote(ticker):
# specify the url
quote_page = 'https://finance.yahoo.com/quote/%s/history/' % 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')
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
# retourne la prière ligne
return data[0]