@
@
@falong2020-05-23 22:58:42
Python
@falong, 2020-05-23 22:58:42

Detect file download time from VK in python?

How to detect the download time of a file from VK in python?

import urllib.request
url = "https://любаяпикча.jpg"
img = urllib.request.urlopen(url).read()
out = open("img.jpg", "wb")
out.write(img)
out.close

The console should unsubscribe for how long the file was downloaded in ms

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Yakushenko, 2020-05-23
_

import urllib.request
import time

url = "https://любаяпикча.jpg"
start_time = int(round(time.time() * 1000))
img = urllib.request.urlopen(url).read()
out = open("img.jpg", "wb")
out.write(img)
out.close
end_time = int(round(time.time() * 1000)) - start_time
print(end_time)

S
Sergey Karbivnichy, 2020-05-23
@hottabxp

It is possible like this:

from datetime import datetime

start = datetime.now()

# Ваш код

end = datetime.now()
print(end-start)

How to convert time to ms, I think you'll figure it out.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question