3 ms·
Nicely done, very clear and concise. A question: is lxml what we would use today instead of Beautiful Soup?
by sixtofour 15y ago
Nicely done, very clear and concise.
A question: is lxml what we would use today instead of Beautiful Soup?
- waterside81 15y agolxml is definitely faster, but I've found BSoup to be more forgiving with poorly formatted DOMs
- kenneth_reitz 15y agoBeautifulSoup is poorly maintained — you have to be very specific with which version you're using. Note: Lxml has a number of repair modes that allows it to parse virtually anything. Cpu cycles and memory go up quite a bit when they're activated, but it's still better than BeautifulSoup.
- ericflo 15y agoThankfully lxml has a slower-but-more-forgiving mode that you can use when interacting with poorly formatted HTML, which takes advantage of BeautifulSoup http://lxml.de/elementsoup.html http://lxml.de/elementsoup.html
- sudont 15y agoI’ve found the exact opposite. BSoup will choke on invalid tags in the DOM, such as: <div id=“content”><content>…</content></div> If I try to return the innerHTML of #content, I get '<div id=“content”><content>’ as a string, nothing else. While I know that’s inexcusable markup, it’s nothing I have control over. lxml (if it builds on the target system) has been much better for my scripts.
- Tobu 15y agolxml's default parsers are good for xml, atom and xhtml; for html5 and html tag soup, lxml.html.html5parser (which depends on html5lib) is the way to go. For feed tag soup, feedparser still uses BeautifulSoup internally.