How can I scrape this site python and websockets?

Viewed 154

Hi I am to use websockets to request data from this site https://dexscreener.com/new-pairs. I previously managed to scrape this site through requests like so:

from requests_html import HTMLSession

session = HTMLSession()
r = session.get('https://dexscreener.com/new-pairs')
r.html.render(sleep=5)

This no longer reaches the <main> tag of data which I would like to read. I feel like I am close to getting a websockets method to work but not quite there yet

import json, socketio

sio = socketio.Client()

sio.connect("https://io.dexscreener.com/", socketio_path='u/ws3/screener3/')

but this is producing an error:

socketio.exceptions.ConnectionError: Unexpected status code 403 in server response

This is the full websockets path I can see:

"wss://io.dexscreener.com/u/ws3/screener3/?EIO=4&transport=websocket&sid=0hOBuQxbhAw5SHEVAN2F"

How can I get this to work and recieve the desired data in the picture below? thanks chrome websockets inspection

0 Answers
Related