赞
踩
代码如下:
url = ‘http://www.xiaohuar.com/d/file/20170318/a5e3460073df58ed208ae3ec2ff46d07.jpg’
path_name ='xx'
urllib.urlretrieve(url, 'D:\imgs\%s.jpg' % path_name)
错误:
在本地打开图片
解决办法:
header = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) \ AppleWebKit/537.36 (KHTML, like Gecko) \ Chrome/35.0.1916.114 Safari/537.36', 'Cookie': 'AspxAutoDetectCookieSupport=1' } request = urllib2.Request(url, None, header) response = urllib2.urlopen(request) with open("D:\zdq\imgs\%s.jpg" % path_name, "wb") as f: f.write(response.read())
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。