I want to open the url such as https://example.com/test.jpg
and check the size of image.
My idea is using subprocess with curl
?
However,I suspect.. it looks not good
Is there any practice for this purpose?
CodePudding user response:
Solution:
import urllib
from urllib import request
url = "https://example.com/test.jpg"
data = urllib.request.urlopen(url).read()
size = len(data)/1024
print(str(size) " KB")
CodePudding user response:
Maybe a bit unsophisticated but could save the ../test.jpg to a temp folder and run:
import os
os.path.getsize(../test.jpg)
My understanding is that by accessing the website you are essentially downloading it so may as well store it locally for half a second and run your tests