Skip to content

Instantly share code, notes, and snippets.

@kedare kedare/main.py
Created Feb 20, 2019

Embed
What would you like to do?
py-ris-streamer.py
import json
import websocket
import pymongo
from pprint import pprint
# Mongo Connect
mongo = pymongo.MongoClient("mongodb://ris:ris@localhost:27017")
db = mongo.ris
collection = db.changes
# WS Connect
ws = websocket.WebSocket()
ws.connect("wss://ris-live.ripe.net/v1/ws/?client=py-ris-streamer")
params = {
"moreSpecific": True,
"host": "rrc21",
"socketOptions": {
"includeRaw": True
}
}
ws.send(json.dumps({
"type": "ris_subscribe",
"data": params
}))
# Process data
for data in ws:
loaded_data = json.loads(data)
collection.insert_one(loaded_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.