I have made a simple command-line URL downloader in Python. When the user supplies a URL it reads the file from web and saves it in a string, then saves the string in a file on the computer.
I want to add a progress bar. How should I go about it?
Figure out the total size of the file you're downloading. This is often present in the HTTP header Content-Length (which is in bytes).
Keep count of the total data downloaded so far.
The amount of the progress bar that should be filled at any moment is given by the formula: (downloaded so far) / (total size) which is a number between 0 and 1, inclusive.
How to add a progress bar in a Python command-line URL downloader?