So, i'm running python3 and i have lxml installed, and ive noticed
that bs4 is parsing this webpage incorrectly and its causing problems
because a lot of the elements are malformed.
I run this:
Python 3.2.2 (v3.2.2:137e45f15c0b, Sep 3 2011, 17:28:59)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> thefile = open("/Users/markgrandi/Desktop/langref/mx/effects/Iris.html", "r")
>>> from bs4 import BeautifulSoup
>>> soup = BeautifulSoup(thefile)
>>> thefile.close()
>>> outputfile = open("/Users/markgrandi/Desktop/bs4.txt", "w")
>>> outputfile.write(soup.prettify())
104520
>>> outputfile.close()
>>> import lxml.html
>>> thefile = open("/Users/markgrandi/Desktop/langref/mx/effects/Iris.html", "r")
>>> tree = lxml.html.parse(thefile)
>>> thefile.close()
>>> output = open("/Users/markgrandi/Desktop/lxml.txt", "w")
>>> output.write(lxml.html.tostring(tree, pretty_print=True).decode("utf-8"))
81037
>>> output.close()
this is the output:
bs4:
http://pastebin.com/KV38maCY
lxml:
http://pastebin.com/ZfWS11Dg
page that i am loading (iris.html):
http://pastebin.com/L0NFdRJf (or
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/effects/Iris.html)
you can see at line 2768 in the bs4 output, it pretty much dies,
because there is a <script> block that starts out with a <!-- -->, but
the lxml output (line 1139) handles it fine.
any idea on why bs4 is getting tripped up?