为什么req = urllib2.urlopen(url)会报错啊?而且只生成了一个无效图片
我的正则表达式应该没有错
import urllib2
import re
req = urllib2.urlopen('https://www.imooc.com/course/list')
buf = req.read()
listurl = re.findall(r'src.*\.jpg',buf)
listurl = re.sub(r'src="','http:',str(listurl))
i = 0
for url in listurl:
f = open('C:\\Users\\lenovo\\Desktop\\a\\'+str(i)+'.jpg','wb+')
req = urllib2.urlopen(url)
buf = req.read()
f.write(buf)
i = i + 1
print listurl