码迷,mamicode.com
首页 > 编程语言 > 详细

python使用md5处理下载图片

时间:2015-05-01 00:30:55      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

import urllib2
import hashlib


opener = urllib2.build_opener()

req = opener.open("http://avatar.csdn.net/E/5/5/2_sdjtwenzhihao.jpg")
meta = req.info()
file_size = int(meta.getheaders("Content-Length")[0])
content_type = meta.getheaders(Content-Type)[0].split(;)[0]
print file_size, content_type

#D3E373E8E47E785CC2C0997E3D1A4BBC
#d3e373e8e47e785cc2c0997e3d1a4bbc
md5=hashlib.md5(req.read()).hexdigest()
print(md5)
#save the file
#open("2_sdjtwenzhihao.jpg", wb).write(req.read())

 

python使用md5处理下载图片

标签:

原文地址:http://www.cnblogs.com/tv151579/p/4470142.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!