Possible Duplicate:
How to download image using requests
I know that fetching a url is as simple as requests.get
and I can get at the raw response body and save it to a file, but for large files, is there a way to stream directly to a file? Like if I'm downloading a movie with it or something?
Oddly enough, requests doesn't have anything simple for this. You'll have to iterate over the response and write those chunks to a file:
I usually just use
urllib.urlretrieve()
. It works, but if you need to use a session or some sort of authentication, the above code works as well.