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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.