scrape.py 文件源码

python
阅读 39 收藏 0 点赞 0 评论 0

项目:earthview-scraper 作者: tom-james-watson 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号