Ich versuche, mit Python und Beautiful Soup eine HTML-Seite zu parsen und einen Text zwischen zwei bestimmten Tags herauszufiltern. Klappt soweit auch ganz gut, nur werden die Tags (hier "<p></p>") mit angezeigt. Die beiden will ich mit replace() löschen.
Leider bekomme ich folgenden Fehler angezeigt: "TypeError: 'NoneType' object is not callable"
Hier der code:
Code: Alles auswählen
import urllib
from BeautifulSoup import BeautifulSoup
f = urllib.urlopen("http://xxx.de/xxx.html")
s = f.read()
f.close()
soup = BeautifulSoup(s);
res = soup.find("p", { "class" : "css_class" });
str(res);
res.replace('<p class="css_class">', '');
res.replace('</p>', '');
print res;
Gruß,
paigo