The following python script usually works to automatically fill in a login webform:
import requests
payload = {
user : myusrname
password : mypass
...etc...
}
s = requests.Session()
s.post(formurl, data = payload)
r = s.get(protectedurl)
However on some websites, the above seems to fail to start the session. I am looking for what it is that it blocking me from entering the protected page.
On the website (https://www.avanza.se) the form looks like
<form autocomplete="off" class="loginForm clearFix" method="POST"action="/ab/noop">
<input placeholder="Användarnamn" type="text" name="j_username" autocapitalize="none">
<input placeholder="Lösenord" type="password" name="j_password">
<div class="errorToolTipPlacement">
<button class="focusBtn loginButton" type="submit" disabled="disabled">Logga in</button>
<a class="fRight marginTop4px defaultSize plcLink" href="/glomt-uppgift.html">Problem att logga in?</a>
</div>
</form>
I am providing the post request with all the name:value
fields (in this case j_username
and j_password
)
The request succeeds, giving me a status code 200 and then redirects back to the original webpage - not logged in. The url and cookies for the start page and the protected page are the same.
I noticed that the result is the same even if I fill out the wrong username and password.
Am I missing some information to send?
Is it using more complicated authentication that I can't see?
Is it simply blocking automated login bots?