首页 > 解决方案 > 无法在 kaggle 网站中使用 request.post 登录

问题描述

当我调用获取请求时,是否有任何具体原因无法找到authenticity_token。我尝试了很多方法,但 kaggle 不允许我使用脚本登录。

这是我的示例代码:

    #url for tain file
    url='https://www.kaggle.com/c/titanic/download/train.csv'
    #setup session
    headers={"Content-Type":"application/x-www-form- 
    urlencoded","Host":"www.kaggle.com","Origin":"https://www.kaggle.com"\
    ,"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) 
    AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 
    Safari/537.36"}
    with session() as c:
       b=c.get('https://www.kaggle.com/account/login',headers=headers)
       print(b.text)  #***not able to find authenticity_token here***

标签: python-3.xrequestkaggle

解决方案


嗯,你试过Kaggle API吗?您可能会发现它更易于使用。


推荐阅读