module 'urllib' has no attribute 'request'
import re import urllib req = urllib.request.urlopen('https://www.imooc.com/course/list') buf = req.read().decode("utf-8") # listurl = re.findall(r'src=.+\.jpg', buf) listurl = re.findall(r'//img.+?\.jpg', buf) for index,app_id in enumerate(listurl): listurl[index] = str(app_id).replace('//', 'http://') print(index, listurl[index]) print(listurl) i = 0 for url in listurl: f = open(str(i) + ".jpg", "wb+") req = urllib.request.urlopen(url) buf = req.read() f.write(buf) i += 1