Django: Parse urls from a block of text
One liner to parse a a block of text and get all URLs from it. Ideal for a django project where BeautifulSoup is already a dependency.
from BeautifulSoup import BeautifulSoup
from django.utils.html import urlize
urls = [a.get('href') for a in BeautifulSoup(urlize(TEXT_TO_PARSE)).findAll('a')]
Written by Owais Lone
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#