首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

python下载(http)资料并保存

2013-04-05 
python下载(http)文件并保存import urllib2request urllib2.Request(http://www.appchina.com/market/r

python下载(http)文件并保存

import urllib2
request = urllib2.Request("http://www.appchina.com/market/r/639017/com.sohu.inputmethod.sogou.apk?channel=aplus.direct&p=aplus.index&uid=gAJ9cQFVC3ZlcmlmeV9jb2RlcQJVBGt1dWxxA3Mu1UNbT0ifMPYMADcmCTSaFDqhBcjWwME7w&page=appplus.category&ref=appplus.main")

response = urllib2.urlopen(request)

#test
file_size = int(response.headers['content-length'])
print file_zise

#test

with open("E:\\tmp\\tmp.apk", 'wb') as output:
??? while True:
??? ??? buffer = response.read(1024*256)
??? ??? if not buffer:
??? ??? ??? break
??? ??? output.write(buffer)

?

?

热点排行