Progress Bars for Python Downloads
Downloading files with Python is super easy and can even be syntactically simple with robust libraries like requests. However, there is no standard library implementation to show a progress bar in python during a download. In this quick tutorial, we’ll show how to quickly implement such a feature to help avoid guesswork during long downloads.
Introduction: Understanding the Problem
Before we dive in we need to understand all the moving pieces of this problem. This will provide the framework by which we can concoct our approach of showing a progress bar while downloading a file via Python. An outline is as follows:
- Make an HTTP request to download a file
- Metering the transfer of data from the remote server
- Displaying the metering process on the console
The good news is that we don’t have to implement any of this from scratch — or even on a low-enough level that we would need to touch Python’s urllib
.
Step 1 will be handled via the Python requests library and both steps 2 and 3 will…