在执行此代码块时,我无法以post方法的方式从Kaggle网站获取数据。它以status_code 400结尾:
#imports
import requests
requests import session
import os
from dotenv import load_dotenv, find_dotenv
#payload for post
payload = {
'action': 'login',
'username': os.environ.get("KAGGLE_USERNAME"),
'password': os.environ.get("KAGGLE_PASSWORD")
}
print(payload)
#url for train file
url = 'https://www.kaggle.com/c/titanic/download/train.csv'
#setup session
with session() as c:
#post request
c.post('https://www.kaggle.com/account/login', data=payload)
#get request
response = c.get(url)
#print response text
print(response.text)