Last active
August 29, 2015 14:00
-
-
Save jlbelmonte/11063439 to your computer and use it in GitHub Desktop.
apibunny
This file contains hidden or 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
import requests | |
from sets import Set | |
_seed = 'http://apibunny.com/cells/taTKQ3Kn4KNnmwVI' | |
_base = 'http://apibunny.com/cells/' | |
visited = Set() | |
def processJson(json) : | |
cells = json.get('cells')[0] | |
print cells["name"] | |
links = cells['links'] | |
toVisit = [ _base + links[x] for x in [k for k in links if k != "mazes"]] | |
map(visit, toVisit) | |
def visit(url): | |
if url in visited : | |
return | |
document = requests.get(url) | |
visited.add(url) | |
if document : | |
processJson(document.json()); | |
if __name__ == "__main__": | |
visit(_seed) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment