I am trying to login to my bank account using python because there is a link that downloads a CSV of all the purchases I've made in the last time. But when I try to log in using Request I get this error
b'<html>\r\n<head><title>403 Forbidden</title></head>\r\n<body>\r\n<center><h1>403 Forbidden</h1></center>\r\n<hr><center>ING Webserver</center>\r\n</body>\r\n</html>\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n'
This is the code I use to come to that result:
import requests
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36'
}
with requests.Session() as s:
url = "https://mijn.ing.nl/login"
USERNAME = 'username'
PASSWORD = 'password'
s.get(url, headers=headers)
login_data = dict(username=USERNAME, password=PASSWORD, next='/')
s.post(url, data=login_data, )
page = s.get('https://mijn.ing.nl/Login', headers=headers)
print(page.content)
Can anyone help me out why I am getting forbidden? Is it because I am posting in the wrong way? or something else maybe
.get()
is to the login url again. Is that intentional? – Ralf Mar 9 '19 at 13:35