gabalese

cssStyleList.py (xml.minidom)

Apr 16th, 2012
148
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /usr/bin/env python
  2. import os, glob
  3. from xml.dom import minidom
  4.  
  5. path = "OEBPS/Text" # your mileage may vary
  6. list = []
  7. new_list = []
  8.  
  9. def cssList():
  10.  
  11.     for infile in glob.glob(os.path.join(path, '*html')):
  12.         html = minidom.parse(infile)
  13.        
  14.         for node in html.getElementsByTagName('p'):
  15.             list.append(node.getAttribute('class'))
  16.             list.append(node.getAttribute('style'))
  17.            
  18.         for node in html.getElementsByTagName('div'):
  19.             list.append(node.getAttribute('class'))
  20.             list.append(node.getAttribute('style'))
  21.            
  22.         for node in html.getElementsByTagName('span'):
  23.             list.append(node.getAttribute('class'))
  24.             list.append(node.getAttribute('style'))
  25.            
  26.         for node in html.getElementsByTagName('i'):
  27.             list.append(node.getAttribute('class'))
  28.             list.append(node.getAttribute('style'))
  29.            
  30.         for node in html.getElementsByTagName('em'):
  31.             list.append(node.getAttribute('class'))
  32.             list.append(node.getAttribute('style'))
  33.            
  34.         for node in html.getElementsByTagName('strong'):
  35.             list.append(node.getAttribute('class'))
  36.             list.append(node.getAttribute('style'))
  37.            
  38.         for node in html.getElementsByTagName('b'):
  39.             list.append(node.getAttribute('class'))
  40.             list.append(node.getAttribute('style'))
  41.            
  42.         # add tags as required...
  43.        
  44.         for i in list:
  45.             if i not in new_list:
  46.                 if i is not None:
  47.                     if i:
  48.                         new_list.append(i)
  49.     return new_list
  50.    
  51. if __name__ == "__main__":
  52.     for item in (cssList()):
  53.         print item
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×