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

查看:31
本文介绍了如何从 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天全站免登陆