Search code examples
python-3.xrequestkaggle

not able to login using request.post in kaggle website


is there any specific reason that I am not able to find authenticity_token when I am invoking get request. I tried many ways but kaggle is not allowing me to login using script.

here is my sample code:

    #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***

Solution

  • Hmm, have you tried the Kaggle API? You might find it easier to use.