[Python]文件下载

[Python]文件下载

仅供学习,请勿用于违法用途

注意修改
path = (本地储存位置)
url = (网址)
1.csv (文件名)


import requests

headers = {
    "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.162 Safari/537.36"
}

url = ""
path = r"D:\Cache\"

r0 = requests.get(url,headers=headers)
print (r0)

with open(path+'1.csv') as f:
    f.write(r0.content)