Login to web portal using Python
Question: So I have followed many guides on how to login to a portal using python using
urllib2 and to parse it using 'BeautifulSoup'.

I am trying to login to this [webportal](http://academia.srmuniv.ac.in) which
has its login form way nested
[there](http://%20https://academia.srmuniv.ac.in/accounts/signin?_sh=false&hideidp=true&portal=10002227248&client_portal=true&servicename=ZohoCreator&serviceurl=https://academia.srmuniv.ac.in/)

I looked at the from tag in the source and found this

    
    
    <form id="signinForm" action="/accounts/signin.ac" name="signinform" method="post" novalidate="true" autocomplete="off">
    

but the link `https://academia.srmuniv.ac.in/accounts/signin.ac` is invalid.

Can someone help me with this.

**EDIT**

Code used:

    
    
    from bs4 import BeautifulSoup import urllib2 import requests 
    payload = {'username': 'some_username', 'password': 'some_password'} 
    r = requests.get("academia.srmuniv.ac.in/accounts/signin.ac";, params=payload) 
    data = r.text soup = BeautifulSoup(data) print soup.prettify()
    


Answer: As said in comment, you need to understand the difference between a `GET` and
a `POST` request.

Get is a basic http request where parameters are passed by the url. It is very
limited in size and security. Post is a when the parameters are in the body of
the request.

In your case, you need a POST request, so you need to use
`requests.post("academia.srmuniv.ac.in/accounts/signin.ac";, params=payload)`

Also, you need to use a session so that the login persists.

Here is a small code to do that:

    
    
    s = requests.Session()
    r = s.post('your address', payload)
    

Lastly, about the parameters, you need to pass an Email and a Password (look
at the id in the input tags), and the address is relativ to an ifram, but I am
not sure about what is the correct address to give...

So it should gives you:

    
    
    import requests
    from bs4 import BeautifulSoup
    
    s = requests.Session()
    payload = {'Email' : youremail, 'Password' : yourpwd}
    r = s.post('https://academia.srmuniv.ac.in/accounts/signin.ac', payload)
    data = r.text()
    soup = BeautifulSoup(data)
    print soup.pretify()
    

And now to access any page in the web site, you just need to use your session
and get or post:

    
    
    r2 = s.get('some other page behind the login page')
    r3 = s.post('some other page with a post method', payload)
    

