Click Download button to get file!
This post is about how to efficiently/correctly download files from URLs using Python. I will be using the god-send library requests for it. With the following streaming code, the Python memory usage is restricted regardless of the size of the downloaded file: def download_file(url): ... import urllib.request print('Beginning file download with urllib2...') url = 'http://i3.ytimg.com/vi/J---aiyznGQ/mqdefault.jpg' urllib.request.urlretrieve(url, ... Using the Requests library for the 95% of the kinds of files that we want to download. Summary. The Requests package isn't part of Python's standard library. But ... How to download files that redirect using the request package.