您需要 python 才能使用 casper.js 吗?如果是,为什么?

Do you need python to use casper.js ? if so why?

我从不使用 python。我唯一知道的语言是 JavaScript。我使用 node 来做网络工作,我一直在阅读 casper.js 如何抓取网页。所以我想我可以像往常一样使用它。现在我正在安装它,我得到 'python' is not recognized as an internal or external command, operable program or batch file. 我知道这意味着将 python 放在我的路径上。我不想安装 python.

我用JavaScript为什么要安装python?我只是感到困惑,因为 casper.js 最后有一个 js,我认为它会依赖 js 而不是 python。所以你能确认我是否真的需要安装 python。我现在真的不想处理另一种语言。过程简单吗?

是的,casper.js需要Python:http://docs.casperjs.org/en/latest/installation.html

PhantomJS 1.9.1 or greater. Please read the installation instructions for PhantomJS

Python 2.6 or greater for casperjs in the bin/ directory

但是,您的所有 编码 都将在 JavaScript 中。您不必(事实上,不能)在 Python.

中编写 CasperJS 脚本

Do you need python to use casper.js?

是的。

If so, why?

CasperJS 需要 python,因为其开发者选择将 python 用于 its executable entrypoint and internal test runner

关于删除 2.0 版本的 python 依赖关系 discussion(shell 脚本和 node.js 都被提议)。


此外,为了清楚起见:CasperJS 不使用 node.js。节点需要 python 的事实是无关紧要的。 CasperJS 是 PhantomJS 的接口,PhantomJS 是一个无头 webkit 驱动程序,恰好可以由 javascript 编写脚本,但不是建立在 node.js 之上。

来自 Casper 文档:

While CasperJS is installable via npm, it is not a node.js module and will not work with NodeJS out of the box. You cannot load casper by using require(‘casperjs’) in node.