Skip to content

Instantly share code, notes, and snippets.

@sdstrowes
Created June 8, 2018 11:38
Show Gist options
  • Save sdstrowes/e757624bcf5294cd820b53a4fafcad53 to your computer and use it in GitHub Desktop.
Save sdstrowes/e757624bcf5294cd820b53a4fafcad53 to your computer and use it in GitHub Desktop.
import json
import requests
import sys
base_req = "https://atlas.ripe.net/api/v2/measurements/?is_public=true&fields=id&page_size=20000&format=json&type=ping"
outfile = open("output.json", "w")
next_url = base_req
while next_url is not None:
print "Fetching ",next_url
r = requests.get(next_url)
if r.status_code != 200:
sys.exit(1)
j = r.json()
outfile.write(json.dumps(j["results"], indent=2))
next_url = j["next"]
if next_url is None and len(j["results"]) > 0:
next_url = base_req + "&id__gt=" + str(j["results"][-1]["id"])
outfile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment