no, pero a mi no se me genera ningun espacio
mira lo que llevo de mi funcion es lo siguiente:
def lireHistoriqueAction(symbol, deltaday):
import datetime
hoy = datetime.date.today()
mois = hoy.strftime('%m')
jour = hoy.strftime('%d')
annee = hoy.strftime('%Y')
delta = hoy - datetime.timedelta(days = deltaday)
mois1 = delta.strftime('%m')
jour1 = delta.strftime('%d')
annee1 = delta.strftime('%Y')
import urllib.request
request = urllib.request
url = 'http://ichart.finance.yahoo.com/table.csv?s=%s&g='%symbol
url = url + 'd&a=%s&b=%s&c=%s&d=%s&e=%s&f=%s'%(mois1,jour1,ann ee1,mois,jour,annee)
print (url)
fichier = request.urlopen(url)
data = fichier.read()
lines = data.split()
for line in lines:
datos = line.decode().split(',')
print (datos)
pero cuando la pruebo me sale el siguiente error:
http://ichart.finance.yahoo.com/table.csv?s=AAPL&g=d&a=10&b=02&c=2010&d=10&e=10&f= 2010
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
x = lireHistoriqueAction('AAPL',8)
File "C:\Users\valeria\Desktop\ulaval\session 1\Programation python\tp4\tp4.py", line 67, in lireHistoriqueAction
fichier = request.urlopen(url)
File "C:\Python31\lib\urllib\request.py", line 121, in urlopen
return _opener.open(url, data, timeout)
File "C:\Python31\lib\urllib\request.py", line 355, in open
response = meth(req, response)
File "C:\Python31\lib\urllib\request.py", line 467, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Python31\lib\urllib\request.py", line 393, in error
return self._call_chain(*args)
File "C:\Python31\lib\urllib\request.py", line 327, in _call_chain
result = func(*args)
File "C:\Python31\lib\urllib\request.py", line 475, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
es como si no encontrara los datos en internet