How to load a nodejs module in PyV8?

假装没事ソ 提交于 2019-12-02 07:11:38

问题


How can I load a nodejs module in PyV8?

I've read all about how great jsdom is when run with nodejs. Will I get the same dom-traversing benefits if I run v8 inside a Python app, with python "getting" the web resources, then giving the resulting html strings to the v8 instance, which has loaded jsdom internally

(or is this a nonsensical configuration for some reason I haven't thought of yet?)


回答1:


I'm afraid this isn't possible as jsdom requires some node constructs which are not available under vanilla v8. Things like require, core libraries, and the method of sandboxing a window would take a bit of work to pull out of jsdom.

You may want to take a peek at https://github.com/andreasgal/dom.js/



来源:https://stackoverflow.com/questions/9833756/how-to-load-a-nodejs-module-in-pyv8

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