|
加个请求头就可以了
- def jpgDownlerError():
- # 定义请求头
- headers = {
- 'User-Agent': 'Mozilla/5.0'
- }
- image_path = 'http://365imgs.cn/cms/files/88/96/fa32f2dce01e0ae2c962c76c512e14656bae8896.jpg'
- # 添加参数headers=headers
- resp = requests.get(image_path,headers=headers,timeout=(5,5))
- print(resp.status_code)
- with open('a.jpg', 'wb') as wstream:
- wstream.write(resp.content)
- print('图片已下载')
复制代码
|
|