【问题标题】:Is there a way to use readability (text extraction algorithm) and a custom algorithm in python to extract links from text?有没有办法在 python 中使用可读性(文本提取算法)和自定义算法从文本中提取链接?
【发布时间】:2011-06-03 02:59:15
【问题描述】:

有没有办法在 python 中使用可读性(文本提取算法)和自定义算法从文本中提取链接?

我想找出一种方法来提取文本正文中的链接。

1.) 我在 python 中使用可读性https://github.com/gfxmonk/python-readability

2.) 我想以某种方式将提取的文本与原始 html 文本进行比较,以便在文章的实际正文中提取链接。

【问题讨论】:

    标签: python html-content-extraction text-extraction


    【解决方案1】:

    嗯,看起来它返回了一个 BeautifulSoup 树。因此,您应该能够执行以下操作:

    article = page.summary()   # Extract article using readability
    article.findAll("a")       # Return a list of all links in the article
    

    【讨论】:

    • BeautifulSoup 绝对是必经之路。
    • @Sri:Readability 已经使用 BeautifulSoup。它旨在减少页面内容,减去广告、导航等。
    猜你喜欢
    • 2012-06-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-12
    • 1970-01-01
    • 2014-09-09
    • 2021-01-25
    • 1970-01-01
    相关资源
    最近更新 更多