python urllib.request.urlretrieve 403报错解决

opener = urllib.request.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36')]
urllib.request.install_opener(opener)
urllib.request.urlretrieve(img_url, filepath)
微信公众号
手机浏览(小程序)
0
分享到:
没有账号? 忘记密码?