bgp/examples/ris-live.py

27 lines
445 B
Python
Raw Permalink Normal View History

2023-10-21 20:17:50 +00:00
import json
try:
import websocket
except ImportError:
raise SystemExit('missing websocket-client')
ws = websocket.WebSocket()
ws.connect('wss://ris-live.ripe.net/v1/ws/?client=bgpexample')
params = {
'moreSpecific': True,
'host': 'rrc21',
'socketOptions': {
'includeRaw': True
}
}
ws.send(json.dumps({
'type': 'ris_subscribe',
'data': params
}))
for data in ws:
parsed = json.loads(data)
print(parsed['type'], parsed['data'])