# -*- coding: utf-8 -*-
from urlparse import urlparse
url = "http://im.baidu.com/download/BaiduHi_2.4_Beta.exe"
parsedurl = urlparse(url)
net_loc = parsedurl[1]
path = parsedurl[2]
httpConn = httplib.HTTPConnection(net_loc);
httpConn.request("GET", path)
r = httpConn.getresponse()
if r.status == 200:
size = r.getheader('Content-Length')
size = int(size) / 1024
print 'size:', size
print r.getheader('Content-Type') #类型
print r.getheader('Last-Modified') #修改时间
else:
print r.status, r.reason
httpConn.close()
Python 获取下载文件的大小
程序员文章站
2022-03-02 12:40:43
...
转载于:https://www.cnblogs.com/leavingme/archive/2009/08/17/1548220.html
上一篇: Python 获取下载文件大小
下一篇: 爆炒甘蓝这样做,美味又好吃!