Catalog108 / challenges / api/websocket/socketio

Socket.IO protocol (polling transport)

advanced Matching curriculum →

What this challenge teaches

Teaches: Socket.IO wraps payloads with a numeric prefix (0=open, 4=message).

Expected output: GET /api/ws/socketio → "4" + JSON; parse the prefix and remaining body.

Submit your scraper's JSON output to /challenges/api/websocket/socketio/grade (grader endpoint is part of a later phase; URL is reserved now).

Socket.IO's polling transport prepends a numeric type to each message. 0 = open, 2 = ping, 3 = pong, 4 = message. Strip the prefix to decode.

resp = requests.get("https://practice.scrapingcentral.com/api/ws/socketio").text
assert resp.startswith("4"), "not a message frame"
payload = json.loads(resp[1:])