ネット画像の取り込みと保存
824 ワード
import requests
import os
root="D://adb//"
path=root+url.split('/')[-1]
url="http://image.nationalgeographic.com.cn/2017/0211/20170211061910157.jpg"
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(" ")