GAE 的 HTML 解析器

发布于 2024-08-19 22:47:50 字数 407 浏览 3 评论 0原文

通常,我使用 lxml 来满足 HTML 解析需求,但这在 Google App Engine 上不可用。明显的替代方案是 BeautifulSoup,但我发现它在格式错误的 HTML 上太容易被阻塞。目前我正在测试 libxml2dom 并得到了更好的结果。

您发现哪种纯 Python HTML 解析器性能最好?我的首要任务是处理不良 HTML 的能力而不是速度。

Generally I use lxml for my HTML parsing needs, but that isn't available on Google App Engine. The obvious alternative is BeautifulSoup, but I find it chokes too easily on malformed HTML. Currently I am testing libxml2dom and have been getting better results.

Which pure Python HTML parser have you found performs best? My priority is the ability to handle bad HTML over speed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

何以心动 2024-08-26 22:47:50

来自 BeautifulSoup 文档

Beautiful Soup 3.1.0 版在实际 HTML 上的表现明显比 3.0.8 版差

,它可能会帮助您使用这个早期版本。这正是作者本人所推荐的。

您可以假装 Beautiful Soup 版本 3.1.0 从未发布。版本 3.0.8 在 Python 2.3 到 2.6 上仍然可以正常工作。

From the BeautifulSoup documentation:

Version 3.1.0 of Beautiful Soup does significantly worse on real-world HTML than version 3.0.8 does

So, it might help you to use this earlier version. That is precisely what the author himself recommends.

You can pretend that Beautiful Soup version 3.1.0 was never released. Version 3.0.8 still works fine on Python 2.3 through 2.6.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文