首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Web-crawler循环

Web-crawler循环
EN

Stack Overflow用户
提问于 2018-01-02 12:23:47
回答 1查看 241关注 0票数 0

我在我的网络爬虫中写了下面的循环。

它在几秒钟后就会用完。我不知道为什么。

代码语言:javascript
复制
def crawlweb(seed):
    crawled = []
    tocrawl = [seed]
    page = tocrawl[0]
    while tocrawl:
        if page not in crawled:
            tocrawl = tocrawl[1:] + (get_links(get_page(page)))
            crawled.append(page)
    return crawled, tocrawl
EN

回答 1

Stack Overflow用户

发布于 2018-01-03 10:58:31

代码语言:javascript
复制
def crawl_web(seed)
tocrawl = [seed]
crawled = []
while tocrawl:
    page = tocrawl.pop()
    if page not in crawled:
        union(tocrawl, get_all_links(get_page(page)))
        crawled.append(page)
return crawled
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48055551

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档