0

I am trying to use Requests module to login into a site and get the html of the landing page. I am new to these stuff and I can't find a decent tutorial for this. Here's the information that I have about that page HTML of the form for login (url:http://14.139.251.99:8080/jopacv06/html/checkouts)

<FORM NAME="form" METHOD="POST" ACTION="./memberlogin" onsubmit="this.onsubmit= function(){return false;}">


<table class='loginTbl' border='1' align="center" cellspacing='3' cellpadding='3' width='60%'>
   <input type="hidden" name="hdnrequesttype" value="1" />
   <thead>
   <tr>
    <td colspan='3' align="middle" class='loginHead'>Login</td>
   </tr>
   </thead>

   <tbody class='loginBody'>

   <tr>
    <td class='loginBodyTd1' nowrap="nowrap">Employee ID</td>
    <td class='loginBodyTd2'><input type='text' name='txtmemberid' id='txtmemberid' value='' class='loginTextBox' size='30' maxlength='8'/></td>
    <td class='loginBodyTd3' rowspan='2'><input type="submit" class="goclearbutton" value="  Go  "></td>
   </tr><input type='hidden' name='txtmemberpwd' id='txtmemberpwd' value='' />

   </tbody>

   <tfoot>
    <tr>
        <td colspan='3' class='loginFoot'>
            <font class='loginRed'>New Visitor?</font>

            <a href="mailto:[email protected]?subject=New Registration&body=New Registartion Request">Send</a> your registration request to library !

           </td>
       </tr>
   </tfoot>

   </table>
   </form>

I came to know that I may need to set cookie , so the cookie name in the landing page is JSESSIONID(in case that's reqd). And I discovered that once I successfuly log in then I would have to use beautifulSoup to get the details. Please help me how to combine these pieces together.

1
  • short answer - use mechanize or selenium Commented Dec 21, 2015 at 6:42

1 Answer 1

1

You will have to do something like this,

import requests

response = requests.post("http://14.139.251.99:8080/jopacv06/html/checkouts/memberlogin", data = {'txtmemberid': '1'})

if response.status_code == 200:
    html_code = response.text
// Do whatever you want to do further with this HTML now.    
Sign up to request clarification or add additional context in comments.

3 Comments

I tried it with a valid id but its showing the html of some other page again and again.
Did you try hitting the URL from some other tool ? Do you get same result ? You can use tools like Postman REST client chrome plugin...
Thanks , I just included 'txtmemberpwd'=' ' in the data dictionary and it worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.