不用再费时间另存为图片了 enn…真香
import requests
import os
root = "/Users/Downloads/yuwen/"
for i in range(1,135):
url = "https://ha.huatu.com/zt/dzkb/yuwen/6s/images/{}.jpg".format(i)
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("文件保存成功")
else:
print("文件已存在")
except:
print("爬取失败")