mardi 12 juillet 2016

request csv format data from url using python


i wana simply send a request to the following url and recive data in csv format and save on the following location,but doest not work!any help will be appreciated

from urllib import  request

my_url='http://real-chart.finance.yahoo.com/table.csv?s=CSV&a=07&b=9&  c=1996&d=05&e=26&f=2016&g=d&ignore=.csv'

def rciveURL(getURL):
response=request.urlopen(getURL)
csv=response.read()
csv_str=str(csv)
mydstination=r'mori.csv'
fx=open(mydstination,"w")
for line in csv_str:
  fx.write(line+"n")
  fx.closed()

  rciveURL(my_url)

Aucun commentaire:

Enregistrer un commentaire