def recursive_scrape(url, count=0):
# The API seems to link the images in a loop, so we can stop once we see an
# image we have already seen.
if url in seen_photos:
return
seen_photos[url] = True
page = requests.get(url)
photo_json = page.json()
print photo_json
yield photo_json
next_url = 'https://earthview.withgoogle.com' + photo_json['nextApi']
# Yielding from recursive functions is a bit funky
for photo_json in recursive_scrape(next_url, count + 1):
yield photo_json
评论列表
文章目录