Unable to log in to website using POST request
P粉087951442
P粉087951442 2023-09-08 12:18:17
0
1
434

I tried to log in using a POST request from pythonhttps://admin.raptor.softwarebut was unable to log in.

I'm using the following code snippet:

import requests_html session = requests_html.HTMLSession() r = session.get('https://admin.raptor.software') csrf = r.html.xpath('/html/head/meta[4]')[0].attrs['content'] data = { 'client_id': '2', 'client_secret': csrf, 'grant_type': 'password', 'password': 'MYPASSWORD', 'username': 'MYEMAIL' } session.post('https://admin.raptor.software/api/login', data = data)

I need it to publishcsrf, so I use therequests_htmllibrary to get it.

After successful login, I want to print the dashboard HTML using the following code, but it posts the login page HTML above:

r = session.get('https://admin.raptor.software/dashboard') print(r.text)
        Admin         

P粉087951442
P粉087951442

reply all (1)
P粉005134685

Try using

import requests session = requests.Session() r = session.post("https://website.com/example/login", data={ "username": "username here", "password": "password here" }) r = session.get("https://website.com/example/dashboard") print(r.text)

What this script does is, it does everything as your script does, but I use requests instead of requests_html

I tried my script on Google and other platforms and it worked.

Hope it’s useful!

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!