Answer the question
In order to leave comments, you need to log in
Download files with download percentage?
Hey! Is it possible through Python to download a file from the internet from a link and get the download percentage in real time?
On the Internet I found how to download the file from the link:
import requests
f = open(r"test.exe", "wb") #открываем файл для записи, в режиме wb
ufr = requests.get("site.com/test.exe") #делаем запрос
f.write(ufr.content) #записываем содержимое в файл; как видите - content запроса
f.close()
Answer the question
In order to leave comments, you need to log in
You need to turn to content-length
the headers, and load them in chunks, and in fact, iter_content(chunk_size=ххх)
you can already calculate the percentages, knowing the size of the content and the size of the chunk. Only it would be nice to be mortgaged, which content-length
may not be.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question