[英]Javascript Execution Through Python
I am attempting to create an html document parser with Python. 我试图用Python创建一个html文档解析器。 I am very familiar with jQuery and I would like to use its traversing functionality to parse these html files and return the data gathered with jQuery back to my Python program. 我对jQuery非常熟悉,我想使用它的遍历功能来解析这些html文件,并将使用jQuery收集的数据返回给我的Python程序。
Is there any way to use javascript scripts through Python? 有没有办法通过Python使用javascript脚本? Or is this just a pipe dream? 或者这只是一个梦想?
jQuery itself does not contain an HTML/XML parser at all. jQuery本身根本不包含HTML / XML解析器。 It uses the browser to do all its parsing. 它使用浏览器进行所有解析。 Thus, even if you figure out how to run Javascript from Python, it won't do you any good. 因此,即使你弄清楚如何从Python运行Javascript,它对你没有任何好处。
Well from your question it seems you will require python-javascript bridge like Pyjamas http://pyjs.org/ , PyPy http://codespeak.net/pypy/dist/pypy/doc/ , skulpt http://www.skulpt.org/ . 从您的问题来看,似乎您将需要python-javascript桥,如睡衣http://pyjs.org/,PyPy http://codespeak.net/pypy/dist/pypy/doc/,skulpt http://www.skulpt .org / 。 Or my personal favorite PyXPCOM http://pyxpcomext.mozdev.org/ it installs a python backend directly into the firefox browser and using xpi stubs one can make bidirectioal calls ( mind you very complicated ) 或者我个人最喜欢的PyXPCOM http://pyxpcomext.mozdev.org/它将python后端直接安装到firefox浏览器中并使用xpi存根可以进行双向呼叫(请注意,你很复杂)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.