Using python requests library to login to website

前端 未结 1 664
借酒劲吻你
借酒劲吻你 2020-12-18 09:05

I have looked through many SO threads on how to create a session using the requests library, but none of the methods I tried actually log me in. I have very little experienc

相关标签:
1条回答
  • 2020-12-18 09:19

    @DanAlbert pointed out that I was telling you to use HTTP Auth which isn't what you're trying to do. I assumed since everything looked correct that it might just be HTTP Auth that you needed.

    However, looking at the form it looks like maybe you're just using the wrong variable name in your dict:

    import requests
    s = requests.session()
    login_data = dict(email='email', password='password')
    s.post('https://account.guildwars2.com/login', data=login_data)
    r = s.get('https://leaderboards.guildwars2.com/en/na/achievements/guild/Darkhaven%20Elite')
    print r.content
    

    If you look at the form it's expecting the variables "email" and "password". You have "username" and "password"

    Anyway, HTH

    0 讨论(0)
提交回复
热议问题