为何下载下来的图片是错位失真的
代码:
import urllib2 import re req = urllib2.urlopen('https://www.imooc.com/course/list') buf = req.read() image_link = re.findall(r'//img.+\.(?:jpg|png)',buf) print image_link print len(image_link) i = 0 for url in image_link: print url f = open(str(i)+'.jpg','w') req = urllib2.urlopen('http:'+url) buf = req.read() f.write(buf) i+=1
下载图片共42张,大部分效果如下: