网络图片
http://www.example.com/**picture.jpg**
国家地理:
http://www.nationalgeographic.com.cn/
选择一个图片Web页面
http://www.nationalgeographic.com.cn/photography/photo_of_the_day/3921/html
本次爬取图片地址
http://a3.att.hudong.com/14/75/01300000164186121366756803686.jpg
全代码
import requests
import os
url = "http://a3.att.hudong.com/14/75/01300000164186121366756803686.jpg"
root = "D://pics//"
path = root + url.split('/')[-1]
try:
if not os.path.exists(root):
os.mkdir(root)
if not os.path.exists(path):
r = requests.get(rul)
with open(path, 'wb') as f:
f.write(r.content) // r.content返回二进制内容
f.close()
print("SECCUSS")
else:
print("FILE EXIST")
except:
print("ERROR")