2016-10-31 4 views
0

Auf this Webseite gibt es eine Schaltfläche "Exportieren nach Excel". Der Befehl mit diesem Link verbunden sind, sollten sein:Python: Datei von der Webseite herunterladen, ashx

https://www.animasgr.it/IT/Prodotti/Quotazioni-e-Performance/_layouts/15/GetExcel.ashx?type=QuoteFondo&code=A60A&i=03.06.1985&f=27.10.2016

Wie kann ich diesen Befehl von einem Python-Skript aufrufen, die Datei dowload? Was ich versucht ist:

response = urllib2.urlopen(https://www.animasgr.it/IT/Prodotti/Quotazioni-e-Performance/_layouts/15/GetExcel.ashx?type=QuoteFondo&code=A60A&i=03.06.1985&f=27.10.2016) 

In [12]: response 
Out[12]: <addinfourl at 4504653336 whose fp = <socket._fileobject object at 0x10cf9e550>> 

Antwort

1

Sie Anfragen können Modul:

import requests 

url_file = 'https://www.animasgr.it/IT/Prodotti/Quotazioni-e-Performance/_layouts/15/GetExcel.ashx?type=QuoteFondo&code=A60A&i=03.06.1985&f=27.10.2016' 
resp = requests.get(url_file) 

with open('anyfilename.xls', 'wb') as f: 
    f.write(resp.content) 

Verwandte Themen