Skip to content

Instantly share code, notes, and snippets.

@itkr
Created May 25, 2015 07:23
Show Gist options
  • Save itkr/964bf79235e995cbb63d to your computer and use it in GitHub Desktop.
Save itkr/964bf79235e995cbb63d to your computer and use it in GitHub Desktop.
Auto HTML Formatter
# -*- coding: utf-8 -*-
#!/usr/bin/env python
import codecs
import sys
from bs4 import BeautifulSoup
def main(argv):
file_path = argv[1]
with open(file_path, 'r') as f:
html = BeautifulSoup(f.read()).prettify()
with codecs.open(file_path, 'w', 'utf-8') as f:
f.write(html)
if __name__ == '__main__':
main(sys.argv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment