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)
评论列表
文章目录