0

I am trying to login into a website from a python script. I read a few tutorials about it and currently I'm stuck at the process to get the login form from the website (how to name the data for username and password). The login button on the website just redirects to another site. On this site a web browser prompt pops up like this

enter image description here

... and ask me to enter the credentials. I was using the inspect tool in chrome to check the traffic during login but there wasn't any POST requests. Only one GET request after login.

Is there a way to get to know the login form for a POST request? Or is a POST request the right way to login on this website at all?

Thanks for you tips and help in advance. Martin

M. K.
  • 3
  • 1

1 Answers1

0

Looks like Basic Auth to me (See Mozilla Developer Network for reference). Assuming your using requests library in python you could give HTTPBasicAuth from requests.auth a try. From https://requests.readthedocs.io/en/latest/user/authentication/ :

from requests.auth import HTTPBasicAuth
basic = HTTPBasicAuth('user', 'pass')
requests.get('https://httpbin.org/basic-auth/user/pass', auth=basic)
PHagemann
  • 71
  • 5
  • Thank you for your answer, it was very helpful! Now I am receiving an OK (200) as an answer for the protected site. Unfortunately when I change the URL to the link with the picture I get a Forbidden answer (403), although I send the 'auth=basic' with it. I used the same get method. Is that right or do I need a different method? – M. K. Nov 06 '22 at 17:48
  • Are you using the Auth for both requests? Although there could be some session depended cookies. You could try to use a persistent session for both requests. See the answer to this question: https://stackoverflow.com/questions/12737740/python-requests-and-persistent-sessions – PHagemann Nov 07 '22 at 01:56