Created
November 8, 2018 15:19
-
-
Save emileaben/e2af6bc456a598c44a84ab760913d19f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import requests | |
import time | |
ips = set() | |
for line in sys.stdin: | |
# assume its well formed | |
line = line.rstrip('\n') | |
ips.add( line ) | |
bobross_url = "https://ipmap.ripe.net/api/v1/locate/all/?resources=%s" % (",".join( ips ) ,) | |
r = requests.get( bobross_url ) | |
#time.sleep( len( ips ) ) # TODO some formula for this | |
# now fetch | |
for ip in ips: | |
skeletor_url = "https://ipmap.ripe.net/api/v1/locate/%s/partials/single-radius" % ( ip ) | |
r = requests.get( skeletor_url ) | |
locs = r.json()["partials"][0]["locations"] | |
if len( locs ) > 0: | |
print "%s %s" % (ip, r.json()["partials"][0]["locations"][0]) | |
else: | |
print "%s NULL" % (ip, ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment