Making POST request in Python
Question: This is the form I am working with.

    
    
    <form name="form1" method="post" action="http://lumbininet.com.np/eservice/index.php/login/processLogin" id="login_form">
    <input type="hidden" name="logout" value=0>
    <table>                               
    <tr>
    <td colspan="2" class="sub-body-txt" height="10"> 
    
    </td>
    </tr>
    <tr> 
    <td width="135" colspan="2" class="sub-body-txt"><p>Username</p></td>
    </tr>
    <tr> 
    <td colspan="2"><input name="username" type="text" id="username" class="sub-body-txt" size="20"></td>
    </tr>
    
    <tr> 
    <td colspan="2" class="sub-body-txt"><p>Password:</p></td>
    </tr>
    <tr> 
    <td colspan="2"><input name="password" type="password" id="password" AUTOCOMPLETE="off" class="sub-body-txt" size="20"></td>
    </tr>
    <tr>
    <td>&nbsp;
    <input type="hidden" name="port" value="110">
    <input type="hidden" name="rootdir" value="">
    </td>
    </tr>
    
    <tr> 
    <!-- <td colspan="2"><input type="button" value="Login" src="/main/icons/buttn_login.gif"  style="width:100px; " name="Submit" id="login_btn"></td> -->
    <td colspan="2"><input type="submit" value="Login" src=/main/icons/buttn_login.gif" style="width:100px; border-radius:2px; background:#000fff; color:white "name="Submit" id="login_btn"></td>
    </tr>
    <tr> 
    <td height="15" colspan="2" class="s-body-txt-lnk">&nbsp;</td>
    </tr>
    </table>
    </form>
    

It has four fields to fill in viz 'username', 'password', 'port' and
'rootdir'. I am making POST request to this page as:

    
    
    import requests
    proxies = {
        "http":"http://heed:ravi@172.31.103.29:3128",
        "https":"https://heed:ravi@172.31.103.29:3128"
        }
    
    headers = { 'Accept':'*/*',
                'Accept-Language':'en-US,en;q=0.8',
                'Cache-Control':'max-age=0',
                'Connection':'keep-alive',
                'Proxy-Authorization':'Basic ZWRjZ3Vlc3Q6ZWRjZ3Vlc3Q=',
                'If-Modified-Since':'Fri, 13 Nov 2015 17:47:23 GMT',
                'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36'
                }
    
    
    with requests.Session() as c:
        url = 'http://lumbininet.com.np/eservice/index.php/login'
        c.get(url, proxies=proxies, headers=headers)
        payload = {'username': 'myusername', 'password': 'mypassword', 'port':'110', 'rootdir':''}
        c.post(url, data = payload, proxies=proxies, headers=headers)
        r = c.get('http://lumbininet.com.np/eservice/index.php/login/processLogin', proxies=proxies, headers=headers)
        print (r.content)
    

But nothing gets printed when I run this. What am I doing wrong ? Is the link
I am making POST request to wrong ? and what about the field values
(particularly of 'hidden' type) ?

Please help.


Answer: According to the HTML, the `action` defined for the `form` is
`action="http://lumbininet.com.np/eservice/index.php/login/processLogin"`

Thus, your `POST` should be sent to this URL, and not the one you defined
(which was `http://lumbininet.com.np/eservice/index.php/login`)

