Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # Created By Abraham Aranguren <name.surname@gmail.com> Twitter: @7a_ http://7-a.org
- # Reference: http://lxml.de/lxmlhtml.html#cleaning-up-html
- # Requires lxml, installation instructions here: http://lxml.de/installation.html
- # Installation in Backtrack 5: /usr/bin/easy_install --allow-hosts=lxml.de,*.python.org lxml
- # Tip for Ubuntu courtesy of Mario Heiderich: Python2.7-dev is needed to compile this lib properly
- from lxml.html.clean import clean_html
- #ALLOWED_TAGS = ( 'div', 'table', 'tr', 'td', 'b', 'i', 'a', 'p' ) # Phase 2? :)
- class HTMLSanitiser:
- def __init__(self):
- pass
- def CleanThirdPartyHTML(self, HTML):
- return clean_html(HTML)
- # For testing as a standalone script:
- Sanitiser = HTMLSanitiser()
- with open('input.txt') as file:
- print Sanitiser.CleanThirdPartyHTML(file.read())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement