import requests
import os
url = input("Please input URL
")
root = "D://pics//"
kv = {
"User-agent":"Mozilla/5.0"
}
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,headers = kv)
print(r.request.headers)
with open(path,"wb") as f:
f.write(r.content)
f.close()
print("Win!!!")
else :
print("Oh,no!!!")
except:
print("Oh,shit!!!")