download file python requests code example
Example 1: python download file from url
import requests
url = 'https://www.facebook.com/favicon.ico'
r = requests.get(url, allow_redirects=True)
open('facebook.ico', 'wb').write(r.content)
Example 2: requests save file python
with open(r'c:\dl\FrameRecentSessions.csv','wb') as f:
f.write(r.content)
Example 3: python get an online file
import urllib2 # the lib that handles the url stuff
data = urllib2.urlopen(target_url) # it's a file like object and works just like a file
for line in data: # files are iterable
print line