How to interpret JavaScript with Python

后端 未结 5 1923
滥情空心
滥情空心 2021-01-14 06:41

It is possible to run JavaScript with Python? There are any library that makes this possible?

I need to execute some JavaScript, I know that this is possible with so

5条回答
  •  伪装坚强ぢ
    2021-01-14 07:16

    If you already use PyQt and QWebView in it, displaying custom html, the function evaluateJavaScript of QWebFrame may be useful for you:

    # Python
    def runJavaScriptText(self, jsText):
       jsText = 'hello()'  # just to fit javascript example
       self.webView.page().currentFrame().evaluateJavaScript(jsText)
    
    
    // Javascript
    function hello() {
        alert('hello');
    };
    

提交回复
热议问题