Diesmal hab ich nen Problem mit BeautifulSoup bei dem ich wieder nicht weiterkomme
mein Code:
Code: Alles auswählen
soup = BeautifulSoup(html_dat)
comment = """
<tr bgcolor="#484848">
<td widht="50%" style="border-left-width:2px; border-top-width:2px; border-bottom-width:0px; border-right-width:0px; border-style:solid; border-color:#000000; ">
""", autorname,"""
</td>
<td width="50%" align="right" style="border-right-width:2px; border-top-width:2px; border-bottom-width:0px; border-left-width:0px; border-style:solid; border-color:#000000; ">
""", datetime.datetime.today(),"""
</td>
</tr>
<tr>
<td colspan="2" bgcolor="#626262" style="border-width:2px; border-style:solid; border-color:#000000; ">
""", autortext,"""
</td>
</tr>
<tr height="25px">
</tr>
<!--ersetzen-->"""
ersetzen = soup.find(name="<!--", text="ersetzen")
print ersetzen
ersetzen.replaceWith(comment)
html_dat.write(soup)
html_dat.close
Code: Alles auswählen
Traceback (most recent call last):
File "C:\html_seite\vers_2\cgi-bin\gaestebuch.py", line 34, in <module>
ersetzen.replaceWith(comment)
File "C:\Python25\lib\BeautifulSoup.py", line 137, in replaceWith
oldParent.insert(myIndex, replaceWith)
File "C:\Python25\lib\BeautifulSoup.py", line 195, in insert
newChild.parent = self
AttributeError: 'tuple' object has no attribute 'parent'
mfg. Martu