我试图kaggle dataset使用python 下载。但是,通过使用该request方法,我遇到了问题,下载的输出.csv文件是损坏的html文件。
import requests
# The direct link to the Kaggle data set
data_url = 'https://www.kaggle.com/crawford/gene-expression/downloads/actual.csv'
# The local path where the data set is saved.
local_filename = "actsual.csv"
# Kaggle Username and Password
kaggle_info = {'UserName': "myUsername", 'Password': "myPassword"}
# Attempts to download the CSV file. Gets rejected because we are not logged in.
r = requests.get(data_url)
# Login to Kaggle and retrieve the data.
r = requests.post(r.url, data = kaggle_info)
# Writes the …Run Code Online (Sandbox Code Playgroud)