如何从Python调用Javascript函数? [英] How do I call a Javascript function from Python?

查看:431
本文介绍了如何从Python调用Javascript函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开展网络抓取项目。我正在使用的其中一个网站的数据来自Javascript。

I am working on a web-scraping project. One of the websites I am working with has the data coming from Javascript.

有一个关于我之前的一个问题,我可以直接从Python调用Javascript,但我不知道如何实现这一点。

There was a suggestion on one of my earlier questions that I can directly call the Javascript from Python, but I'm not sure how to accomplish this.

例如:如果JavaScript函数定义为: add_2(var,var2)

For example: If a JavaScript function is defined as: add_2(var,var2)

我该怎么称呼它来自Python的JavaScript函数?

How would I call that JavaScript function from Python?

推荐答案

查找具有Python绑定的JavaScript解释器。 (试试Rhino?V8?SeaMonkey?)。当你找到一个时,它应该带有如何在python中使用它的例子。

Find a JavaScript interpreter that has Python bindings. (Try Rhino? V8? SeaMonkey?). When you have found one, it should come with examples of how to use it from python.

然而,Python本身不包含 JavaScript解释器

Python itself, however, does not include a JavaScript interpreter.

这篇关于如何从Python调用Javascript函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆