- Google+ Tools
-
Make Google+ profile picture
Make Google plus banners for profile
Create and share your Google Plus profile banners.
A python script to extract inline CSS in HTML made with some graphical tool (like iWeb).
Only BeautifulSoup installed.
- Language
- Python
- Tags
- pythoncssinlineextractorextracthtmlclean
python css inline extractor
#!/usr/bin/python
from BeautifulSoup import BeautifulSoup as BS
import sys
bs = BS(open(sys.argv[1]).read())
count = 0
styles = []
for t in bs.findAll(True):
if t.get('style'):
myclass = "extracted_%d" % count
styles.append( ".%s { %s }" % (myclass,t.get('style'),))
del t['style']
# has class
if t.get('class'):
t['class'] = t['class'] + " "+ myclass
# no has class
else:
t['class'] = myclass
count+=1
print "\n".join(styles)
print bs.prettify()
Comments
blog comments powered by Disqus