Xpath vs DOM vs BeautifulSoup vs lxml vs other Which is the fastest approach to parse a webpage?

本秂侑毒 提交于 2019-11-27 16:44:04

问题


I know how to parse a page using Python. My question is which is the fastest method of all parsing techniques, how fast is it from others?

The parsing techniques I know are Xpath, DOM, BeautifulSoup, and using the find method of Python.


回答1:


http://blog.ianbicking.org/2008/03/30/python-html-parser-performance/




回答2:


lxml was written on C. And if you use x86 it is best chose. If we speak about techniques there is no big difference between Xpath and DOM - it's very quickly methods. But if you will use find or findAll in BeautifulSoup it will be slow than other. BeautifulSoup was written on Python. This lib needs a lot of memory for parse any data and, of course, it use standard search methods from python libs.



来源:https://stackoverflow.com/questions/8342335/xpath-vs-dom-vs-beautifulsoup-vs-lxml-vs-other-which-is-the-fastest-approach-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!