Beautiful Soup Error... Bug fixing script tags...

10 views
Skip to first unread message

Zimmer

unread,
Oct 24, 2009, 3:04:52 PM10/24/09
to beautifulsoup
Here is the code in a console session that causes the error...

-----------Console-------------


>>> url = "http://www.youtube.com/watch?v=BXPv_7OuT6w"
>>> from BeautifulSoup import BeautifulSoup as BS
>>> src = urllib.urlopen(url).read()
>>> url
'http://www.youtube.com/watch?v=BXPv_7OuT6w'
>>> src = urllib.urlopen(url).read()
>>> soup = BS(src)
>>> BS(src)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\Python 2.6.2\lib\site-packages
\BeautifulSoup.py", line
1499, in __init__
BeautifulStoneSoup.__init__(self, *args, **kwargs)
File "C:\Program Files\Python 2.6.2\lib\site-packages
\BeautifulSoup.py", line
1230, in __init__
self._feed(isHTML=isHTML)
File "C:\Program Files\Python 2.6.2\lib\site-packages
\BeautifulSoup.py", line
1263, in _feed
self.builder.feed(markup)
File "C:\Program Files\Python 2.6.2\lib\HTMLParser.py", line 108, in
feed
self.goahead(0)
File "C:\Program Files\Python 2.6.2\lib\HTMLParser.py", line 148, in
goahead
k = self.parse_starttag(i)
File "C:\Program Files\Python 2.6.2\lib\HTMLParser.py", line 226, in
parse_sta
rttag
endpos = self.check_for_whole_start_tag(i)
File "C:\Program Files\Python 2.6.2\lib\HTMLParser.py", line 301, in
check_for
_whole_start_tag
self.error("malformed start tag")
File "C:\Program Files\Python 2.6.2\lib\HTMLParser.py", line 115, in
error
raise HTMLParseError(message, self.getpos())
HTMLParser.HTMLParseError: malformed start tag, at line 192, column
977


---------</console>-----------


Also here is the offending part of the src (I believe...)

http://paste.pocoo.org/show/146756/

Aaron DeVore

unread,
Oct 24, 2009, 8:54:14 PM10/24/09
to beauti...@googlegroups.com
Zimmer,
Try out Beautiful Soup 3.0.7a. It will probably parse this HTML perfectly well.

-Aaron DeVore

P.S. If you feel like being a guinea pig, you could use my 3.0.7a mod. It's at:

http://github.com/adevore/old-beautiful-soup

David .

unread,
Oct 25, 2009, 5:23:39 PM10/25/09
to beauti...@googlegroups.com
Ya I finally realized that the parser switched and so I just installed BS 3.0.7a and it ran perfect! Sadly all the data I need is in Javascript (can BS parse that too?) :( Any recommendations for JS parsers?

Aaron DeVore

unread,
Oct 26, 2009, 12:58:36 AM10/26/09
to beauti...@googlegroups.com
On Sun, Oct 25, 2009 at 2:23 PM, David . <zim...@gmail.com> wrote:
> Ya I finally realized that the parser switched and so I just installed BS
> 3.0.7a and it ran perfect! Sadly all the data I need is in Javascript (can
> BS parse that too?) :( Any recommendations for JS parsers?

Would a regular expression work?

-Aaron DeVore

Reply all
Reply to author
Forward
0 new messages