请问为什么会出现urllib2.HTTPError: HTTP Error 400: Bad Request错误?
代码如下:
import re
import urllib2
req = urllib2.urlopen('https://www.imooc.com/course/list')
buf = req.read()
#listurl = re.findall(r'src=.+\.jpg',buf)
listurl = re.findall(r'//.+\.jpg*',buf)
#print listurl
i = 0
for url in listurl:
f=open("D:\\python\\LearnPython\\"+str(i)+'.jpg','wb')
req = urllib2.urlopen('http:'+url)
buf = req.read()
f.write(buf)
i=i+1