import requests
import os
root = "d://pics//"
url = "http://img0.dili360.com/pic/2019/04/16/5cb59f9e175f06y17292216_t.jpg"
path = root + url.split('/')[-1] #按/结尾的最后一部分
try:
if not os.path.exists(root):
os.mkdir(root)
if not os.path.exists(path):
r = requests.get(url)
with open(path,'wb') as f:
f.write(r.content)
f.close()
print("Save successfully!")
else:
print("Already existing!")
except:
print("Error!404!")
【爬虫】爬取网页图片
猜你喜欢
转载自blog.csdn.net/qq_41514794/article/details/89716846
今日推荐
周排行