Hello,
I have a big problem with Beautifull soup's replaceWith not working:
I have something like <span class="ngen_F">xxx</span> and want it to be replaced by <b>xxx</b>
my code:
Code:
def preprocess_html(self, soup):
# Change
for fett in soup.findAll(name='span',attrs={'class':'ngen_F'}) :
if fett:
tag = Tag(soup, 'b')
tag.insert(0, fett.contents[0])
print tag
fett.replaceWith(tag)
return soup
print tag works. But replaceWith just replaces with ''
When I do fett.replaceWith('<b>test</b>) this is ok.
What's wrong here?
Stefan