|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
已经知道filename中已经取好了url地址:
filename=each.split("/")[-1]
print(filename)
但是执行下句无法报存本地,报错
urllib.request.urlretrieve(each,filename,None)
报错信息
Traceback (most recent call last):
File "D:/pycharm/小甲鱼/2059正则1.py", line 23, in <module>
get_img(open_url(url))
File "D:/pycharm/小甲鱼/2059正则1.py", line 19, in get_img
urllib.request.urlretrieve(each,filename,None)
File "C:\Program Files\Python37\lib\urllib\request.py", line 247, in urlretrieve
with contextlib.closing(urlopen(url, data)) as fp:
File "C:\Program Files\Python37\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "C:\Program Files\Python37\lib\urllib\request.py", line 531, in open
response = meth(req, response)
File "C:\Program Files\Python37\lib\urllib\request.py", line 641, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Program Files\Python37\lib\urllib\request.py", line 569, in error
return self._call_chain(*args)
File "C:\Program Files\Python37\lib\urllib\request.py", line 503, in _call_chain
result = func(*args)
File "C:\Program Files\Python37\lib\urllib\request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden
Process finished with exit code 1
新手刚学爬虫,照猫画虎,不知什么问题,应该怎么解,求大神解惑!
|
|