4 ms·
I've relied heavily on lxml in the past to parse HTML and I've found it to be quite reliable against tag soup. Do you have any specific gripes or sources I coul
by coderdude 16y ago
I've relied heavily on lxml in the past to parse HTML and I've found it to be quite reliable against tag soup. Do you have any specific gripes or sources I could reference? I'm interested in finding out where it is deficient.
- hoppipolla 16y agoHmm, I only have vague recollections about people reporting problems with lxml and I can't trivially find any supporting evidence with Google so it is possible that it is good enough in almost all cases (since afaik it doesn't actually implement the HTML5 algorithm yet it presumably doesn't work when you need browser-grade compatibility, but such extreme requirements are rare). In any case lxml is a superb library which I would recommend to anyone; personally I often use html5lib with the lxml treebuilder to take advantage of all the nice features in the lxml tree. It is also the best choice I am aware of for fast parsing of possibly broken HTML in python.
- ianb 16y agolibxml2's parser (which lxml uses) was written before HTML 5. It generally works quite well, but I've found a bug or two in it, and it doesn't get updated much. For instance, weird things can happen with tags after the </body> tag (I think maybe you can get a second body or head element). lxml can't parse Google's homepage as another example, but it's an extreme example.