HTMLParser.HTMLParseError : malformed start tag (unclosed br)

138 views
Skip to first unread message

kushal

unread,
Jun 17, 2009, 8:51:30 AM6/17/09
to beautifulsoup, Sudip Datta, prashant ullegaddi, Vinay
Hi All,
I was trying to parse a html file and it gave following error:
---------------------------------------------------------------
Traceback (most recent call last):
File "test.py", line 13, in <module>
soup = BeautifulSoup(data)
File "/usr/lib/python2.5/site-packages/BeautifulSoup.py", line 1499,
in __init__
BeautifulStoneSoup.__init__(self, *args, **kwargs)
File "/usr/lib/python2.5/site-packages/BeautifulSoup.py", line 1230,
in __init__
self._feed(isHTML=isHTML)
File "/usr/lib/python2.5/site-packages/BeautifulSoup.py", line 1263,
in _feed
self.builder.feed(markup)
File "/usr/lib/python2.5/HTMLParser.py", line 108, in feed
self.goahead(0)
File "/usr/lib/python2.5/HTMLParser.py", line 148, in goahead
k = self.parse_starttag(i)
File "/usr/lib/python2.5/HTMLParser.py", line 226, in parse_starttag
endpos = self.check_for_whole_start_tag(i)
File "/usr/lib/python2.5/HTMLParser.py", line 301, in
check_for_whole_start_tag
self.error("malformed start tag")
File "/usr/lib/python2.5/HTMLParser.py", line 115, in error
raise HTMLParseError(message, self.getpos())
HTMLParser.HTMLParseError: malformed start tag, at line 1, column 4
---------------------------------------------------------------
We tried to figure out as to why the error was coming and found out
that it was faltering at the following line:


<br, africam ntion namde djiboiti the Republic of Mauritius is an
island nation off the coast of the African is a landlocked country in
Western Africa, named It is bordered by Djibouti to the northwest,
Kenya <br />

Is there any way to fix these errors?
We are dealing with a larger dataset which involves a lot of deformed
html data, can BS get hold of most of these errors? (for example:
double quotes like "hello world"" , un-ended tags, ill-formed tags
etc)
Reply all
Reply to author
Forward
0 new messages