Catalog108 / challenges / api/websocket/live-prices
Live price feed (polling shim)
What this challenge teaches
Teaches: Poll /api/ws/live-prices every 3 seconds for new "frames" of price updates.
Expected output: Read 5 price frames over 15 seconds and detect changes.
Submit your scraper's JSON output to /challenges/api/websocket/live-prices/grade
(grader endpoint is part of a later phase; URL is reserved now).
Poll /api/ws/live-prices every 3 seconds. Each response carries an array of "frames" (one per price tick).
import time, requests
seen_prices = {}
for _ in range(5):
r = requests.get("https://practice.scrapingcentral.com/api/ws/live-prices").json()
for f in r["frames"]:
if seen_prices.get(f["symbol"]) != f["price"]:
print(f["symbol"], "→", f["price"])
seen_prices[f["symbol"]] = f["price"]
time.sleep(3)