I have a collection of HTML files. I wish to iterate over them, one by one, editing the mark-up of a particular class. The code I wish to edit is of the following form, using the following class names :
<td class='thisIsMyClass' colspan=4>
<a id='123' class='thisIsMyOtherClass' href='123'>Put me Elsewhere</a>
This can occur multiple times in the same document, with different text instead of "Put me Elsewhere", but always the same classes.
I want to change this to be of the form :
<font SIZE="3" COLOR="#333333" FACE="Verdana" STYLE="background-color:#ffffff;font-weight: bold;">
<h2>Put Me Elsewhere</h2>
</font>
import os
for filename in os.listdir('dirname'):
replace(filename)
def replace(filename):
tags = soup.find_all(attrs={"thisIsMyClass"})
Not too sure where to go after this or how to deal with the tags array? Any help would be much appreciated. Thanks :)