I want to connect to a websocket to process real time data. The URL look like this: https://testsite.test.de/Interfaces
. When I enter it in Firefox it asks immediately for username and password. After I enter them the status codes are 200 with HTTP/1.1, 200 HTTP/2, 101 switching protocols connection upgrade and the Scheme changes to wws://.
With this code I can log in and get the status code 200 with print(r):
import requests
headers = {'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:125.0) Gecko/20100101 Firefox/125.0'}
r = requests.get('https://testsite.test.de/Interfaces',
auth=('my_username', 'my_password'), headers=headers)
print(r)
print(r.cookie) is empty.
I do not know the next steps to get the data.
I tried this with no result:
import websocket
ws = websocket.WebSocketApp('wss://testsite.test.de/Interfaces')
ws.run_forever
This is what the Inspector shows: