Tuesday, April 21, 2015

How to download a file from the internet by its URL

download_files

Download a file from the internet

In [1]:
import urllib
In [2]:
url_to_download = 'http://real-chart.finance.yahoo.com/table.csv?s=AAPL'
save_as_file = 'aapl.csv'
In [3]:
urllib.urlretrieve(url_to_download, save_as_file)
Out[3]:
('aapl.csv', <httplib.HTTPMessage instance at 0x000000000A0C9EC8>)