Commits

Ed Brannin committed c925f45

Now cleaning up the code a smidge.

Comments (0)

Files changed (1)

 #!/usr/bin/python
 
-from BeautifulSoup import BeautifulSoup, HTMLParser
+from BeautifulSoup import BeautifulSoup, HTMLParser, NavigableString
 import os, sys
 
 def handle(path):
   try:
     soup = BeautifulSoup(file(path))
-    scripts = soup.findAll('script')
-    if len(scripts) > 1:
-      print "%s has %d scripts!" % (path, len(scripts))
-    else:
-      #print path
-      pass
   except:
     print "%s has an error: %s" % (path, sys.exc_info()[1])
+    return
+  for tag in ['style', 'script']:
+    [s.extract() for s in soup.findAll(tag)]
+  for tag in ('font', 'span', 'b', 'i'):
+    for s in soup.findAll(tag):
+      s.replaceWith(NavigableString(s.renderContents()))
+  print "Title: " + soup.title.renderContents()
+  print soup.prettify()
+
+  raise "Stop!"
 
 try:
   path = sys.argv[1]