def getlinks(value): try: import beautifulsoup except ImportError: if settings.DEBUG: raise template.TemplateSyntaxError, "Error in {% getlinks %} filter: The Python BeautifulSoup and/or urllib2 libraries aren't installed." return value else: soup = beautifulsoup.BeautifulSoup(value) return soup.findAll('a') """ Returns links found in an (X)HTML string as Python objects for itteration in templates. EXAMPLE: """