Why doesn't Node.js have a native DOM?

前端 未结 13 1641
既然无缘
既然无缘 2020-11-28 08:32

When I discovered that Node.js was built using the V8 JavaScript engine, I thought:

Great, web scraping will be easier as the page

13条回答
  •  孤城傲影
    2020-11-28 09:08

    You seem to have a flawed assumption that V8 and the DOM are inextricably related, that's not the case. The DOM is actually handled by Webkit, V8 doesn't handle the DOM, it handles Javascript calls to the DOM. Don't let this discourage you, Node.js has carved out a significant niche in the realtime server market, but don't let anybody tell you it's just for servers. Node makes it possible to build almost anything with JavaScript.

    It is possible to do what you're talking about. For example there is the very good jsdom library if you really need access to the DOM, and node-htmlparser, there are also some really good scraping libraries that take advantage of these like apricot.

提交回复
热议问题