utils.py 文件源码

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

项目:socialhome 作者: jaywink 项目源码 文件源码
def find_urls_in_text(text):
    """Find url's from text.

    Bleach does the heavy lifting here by identifying the links.

    :param text: Text to search links from
    :returns: set of urls
    """
    urls = []

    def link_collector(attrs, new=False):
        href_key = (None, "href")
        urls.append(attrs.get(href_key))
        return None

    bleach.linkify(text, callbacks=[link_collector], parse_email=False, skip_tags=["code"])
    return set(urls)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号