HTMLParser problems.
Paul Clinch
pclinch at internet-glue.co.uk
Fri Oct 31 16:50:06 EST 2003
You could patch it with:=
def handle_starttag(self,tag,attrs):
if tag == "td":
self.in_td = 1
self.row.append("")
elif tag == "tr":
self.in_tr = 1
def handle_data(self,data):
if self.in_td == 1:
data = string.lstrip(data)
if data != "":
self.row[-1]=data
i.e. create the element and then later possible replace it.
BTW True can be used as 1, an empty string is false, strings have
methods and "if self.in_td:" ok, so:-
def handle_data(self,data):
if self.in_td:
data = data.lstrip()
if data:
self.row[-1]=data
is equivalent.
Regards, Paul Clinch
More information about the Python-list
mailing list