SHARE
TWEET

Untitled

a guest Jul 14th, 2012 17 Never
  1.         dom = BeautifulSoup(untrusted_html)
  2.  
  3.         def cleanHtml(dom):
  4.             for a in dom.findAll('a'):
  5.                 a['rel'] = "nofollow"
  6.  
  7.             map(lambda x: x.extract(), dom.findAll(['script', 'object', 'link', 'style']))
  8.             return unicode(dom)
RAW Paste Data
Top