thanks to this thread i was able to connect to tradingview socket with pyppeteer. But i am not able to work with the response otherwise i block the whole program. I can also not make the function "printResponse" async because then i can not call it with "cdp.on('Network.webSocketFrameReceived', printResponse)" anymore. Can anyone help?
it block at line "response = json.loads(response)"
import asyncio
from pyppeteer import launch
import json
async def main():
browser = await launch(
headless=True,
args=['--no-sandbox'],
autoClose=False
)
page = await browser.newPage()
await page.goto('https://www.tradingview.com/symbols/BTCUSD/')
cdp = await page.target.createCDPSession()
await cdp.send('Network.enable')
await cdp.send('Page.enable')
def printResponse(response):
response = json.loads(response)
print(response)
cdp.on('Network.webSocketFrameReceived', printResponse) # Calls printResponse when a websocket is received
cdp.on('Network.webSocketFrameSent', printResponse) # Calls printResponse when a websocket is sent
await asyncio.sleep(100)
asyncio.get_event_loop().run_until_complete(main())