我需要在Python中运行javascript代码。这个JS代码使用document
DOM对象函数,我不知道如何在JS代码中“创建DOM对象”来使用它。在
目前我调用的JS文件如下:
import json
import PyV8
def runJS(html):
ctxt = PyV8.JSContext()
ctxt.enter()
ctxt.eval(open('JScode.js').read().decode('utf8'))
document = {'body': html.decode('utf8')}
result = ctxt.eval('run(%s);' % json.dumps(document))
在JScode.js文件的功能如下:
^{pr2}$在JScode.js我使用的方法有:
document.getElementById();
document.getElementByTagName();
document.evaluate();
document.querySelectorAll();
我该怎么做?在
目前没有回答
相关问题 更多 >
编程相关推荐