__init__.py 文件源码

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

项目:wikiphilosophy 作者: adtac 项目源码 文件源码
def next_link(cur, done):
    try:
        g = wikipedia.page(cur).html()
    except wikipedia.exceptions.DisambiguationError as e:
        for op in e.options:
            if op not in done:
                g = wikipedia.page(op).html()
                break
    soup = BeautifulSoup(re.sub(r'\([^)]*\)', '', g), "html.parser")
    for para in soup.findAll("p"):
        flag = False
        for link in para.findAll("a"):
            flag = True
            if link.get("href").startswith("/wiki/") and link.get("title") not in done and link.contents[0].islower():
                return link.get("title")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号