Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
parse_ripe_atlas_dns.py
#!/usr/bin/python
# pip install ripe.atlas.sagan
# pip install dnspython
import json
from ripe.atlas.sagan import DnsResult
import base64
import dns.message
import urllib
import time
f = urllib.urlopen('https://atlas.ripe.net/api/v2/measurements/6929346/results?start=1478563200&stop=%s&format=json' % int(time.time()))
contents = json.load(f)
for content in contents:
dns_result = DnsResult.get(content)
dnsmsg = dns.message.from_wire(base64.b64decode(str(dns_result.responses[0].abuf)))
# print str(dnsmsg)
# print str(dns_result),
print dns.rcode.to_text(dnsmsg.rcode()) #, " ", dnsmsg.answer[0].ttl
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.