1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] How can I use cookies in Python Requests?

Discussão em 'Python' iniciado por Stack, Outubro 1, 2024 às 04:42.

  1. Stack

    Stack Membro Participativo

    I am trying to log in to a page and access another link in the page.

    I get a "405 Not Allowed" error from this attempt:

    payload={'username'=<username>,'password'=<password>}
    with session() as s:
    r = c.post(<URL>, data=payload)
    print(r)
    print(r.content)


    I checked the post method details using Chrome developer tools and found a URL that appeard to be an API endpoint. I posted to that URL with the payload and it seemed to work; I got a response similar to what I could see in the developer.

    Unfortunately, when trying to 'get' another URL after logging in, I am still getting the content from the login page. Why is the login not sticking? Should I use cookies? How?

    Continue reading...

Compartilhe esta Página