Log in to website using Python Requests module -


i'm trying use requests module log in website. i'm not sure reference in html form post username , password. here form i'm trying use post log in:

<div class="login-box contents" id="login">                         <!--<div class="login-instruction">                             <label class="fl-label"> enter information below login. </label>                         </div>-->                         <div class="login-username">                             <label for="username" class="fl-label">username: </label>                             <div class="clearboth"></div>                               <input id="proxyusername" name="proxyusername" class="required" tabindex="1" maxlength="100" type="text" value="" onchange="remove_error()" autocomplete="off"/>                          </div>                         <div class="float-right">                             <b><input type="checkbox" id="proxyrememberuser" name="proxyrememberuser" tabindex="-1" value="checked">&nbsp;remember username</input></b>                         </div>                         <br/>                         <div class="login-password">                             <label for="password" class="fl-label">password: </label>                             <div class="clearboth"></div>                              <input id="proxypassword" name="proxypassword" class="required" tabindex="2" maxlength="50" type="password" value="" onchange="remove_error()" autocomplete="off" />                         </div> 

i'm trying figure out where/how in form tell put username , password. in code below, keys payload_login variable not correct:

import requests   username = raw_input('please enter username: ') password = raw_input('please enter password: ')  payload_login = {     'username': username,     'password': password }  requests.session() s:     con = s.post('somewebsite.com', \        data=payload_login) 

as @hlt have commented, must name field same, named in form.

also server may validate "remember username" checkbox, better include in request.

payload_login = {     'proxyusername': username,     'proxypassword': password,     'proxyrememberuser': true } 

if not work you, means site send auth-data different way. example, js-script may add hidden data in request, or encode fields.

to find out, need search http-request in browser's developter panel or in external http-sniffer (like fiddler).


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -