import requests
import os
url="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=460770515,1829173594&fm=26&gp=0.jpg"
headers={
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
}
html=requests.get(url=url,headers=headers).content
#保存文件到本地文件
directory = './images/'
if not os.path.exists(directory):
os.makedirs(directory)
filename=directory+url[-10:]
with open(filename,"wb") as f:
f.write(html)