#图片爬虫.py
import requests
r=requests.get('https://pics7.baidu.com/feed/023b5bb5c9ea15ce57c3522b4f1e4dfb3a87b28e.jpeg?token=6944f3ea4714d039b2fdaa329729bbd1') #链接填入引号之间
path='../picture/jk.jpg' #为图片命名
try:
f=open(path,'wb')
f.write(r.content)
f.close()
print('文件保存成功')
except:
print('爬虫失败')

本文介绍了如何使用Python requests库从指定URL抓取图片,并保存到本地,同时处理可能出现的网络请求异常。
2563

被折叠的 条评论
为什么被折叠?



