I try to log in to the site, but it does not work.

import requests from requests.auth import HTTPDigestAuth url_login = r'https://onlinebanking.mtb.com/Login/MTBSignOn' r = requests.get(url_login, auth=HTTPDigestAuth('Login', 'Pass')) 

This error occurs:

Internal Server Error

Internal Server Error - Read

I was unable to complete your request.

Tell me what am I doing wrong?

I also tried to do this:

 payload = { 'UserId': 'Login', 'Passcode': 'Pass', } headers = { 'Host': 'onlinebanking.mtb.com', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Language': 'ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3', 'Accept-Encoding': 'gzip, deflate, br', 'Referer': 'https://onlinebanking.mtb.com/Login/MTBSignOn', 'Content-Type': 'application/x-www-form-urlencoded', 'Connection': 'keep-alive' } r = requests.post(url_login, data=payload, headers=headers) 

But authorization does not pass.

  • And in the second case, what error happens? - Alexander
  • The get method should be used and cookies should be inserted, and you would try to log in to the CIA in this way - Alexander

1 answer 1

You send the request without cookies. You need to first go to the login page, save the transmitted cookies, and then send the login request with the saved cookies. The easiest way to do this is to use the session object .

The fact that cookies are needed is easy to see in the developer’s tools.

The arrow points to the cookie header.

Necessary parameters except login and password you can peek in the same place.