Home » Javascript » How to determine post request inputs using javascript

How to determine post request inputs using javascript

Posted by: admin August 19, 2018 Leave a comment


I am trying to login to a website using python but not having much success. Whenever I post my credentials, I get a 200 response but I’m redirected to the login screen. I think this is because the website’s login is using javascript that requires more than just a username and password in the post command, but I’m not sure how to parse it to fix my login code.

This is my python code:

s = requests.session()
login_url = "example.com"
result = s.get(login_url)
payload = {
    "user_login": "xx", 
    "user_pass": "xx"
postresult = s.post(
    data = payload,

Here’s what the input form looks like:

<div id="loginForm">
                <input class="txt" type="email" name="user_login" tabindex="1" value="">
                <input class="txt" type="password" name="user_pass" tabindex="2">
            <li class="submit">
                <a id="a-fgt" class="sub" href="#" tabindex="4">Forgot Password</a>
                <input type="submit" id="logSubmit" value="Login" tabindex="3" />
                <div id="rightBlock">
                    <span id="respMsg"></span>

And here’s part of the javascript code that’s executing:

function init_login(){
    var form = document.forms.loginForm;

    var lgn = getCookie('login');
        if(lgn){form.user_login.value = lgn;}

        formVal = new FormValidator(form);

/*---\\ LOGIN FUNCTIONS ///---*/
    function login_request(form){
        form = validateForm(form, 'user_pass');