Advertisement
Guest User

Untitled

a guest
Jul 1st, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. from bs4 import BeautifulSoup
  2. import os, sys
  3.  
  4. def htmlHandler(html_code, file):
  5.     wof_file = open("wof_files/{0}".format(file), 'w')
  6.     a = BeautifulSoup(html_code)
  7.     [x.extract() for x in a.findAll('footer')]
  8.     wof_file.write(str(a));
  9.     wof_file.close()
  10.  
  11. def fileHandler(dir):
  12.     if not os.path.exists('wof_files'):
  13.         os.mkdir('wof_files')
  14.     htmlFiles = os.listdir(dir)
  15.     for file in htmlFiles:
  16.         htmlHandler(open(os.path.join(dir, file)).read(), file)
  17.  
  18.  
  19. def main():
  20.     fileHandler(sys.argv[1])
  21.  
  22. if __name__ == '__main__':
  23.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement