如何从phantomjs shell中运行casper?

如何从phantomjs shell中运行casper?,phantomjs,casperjs,Phantomjs,Casperjs,有人知道在phantomjs shell(又称为phantomjs shell)中是否可以运行casperjs,以及如何运行casperjs吗 我还尝试将直接路径传递到casper.js模块,但这也没有起作用 进度/更新: 尝试phantomjs.injectJs('C:/casperjs/module/casper.js')但出现错误:找不到模块“着色器”我想我快找到了 这让我走得更近了,但仍然迷失了方向: phantomjs.injectJs('C:/casperjs/module/b

有人知道在phantomjs shell(又称为phantomjs shell)中是否可以运行casperjs,以及如何运行casperjs吗

我还尝试将直接路径传递到casper.js模块,但这也没有起作用

进度/更新:

  • 尝试
    phantomjs.injectJs('C:/casperjs/module/casper.js')但出现
    错误:找不到模块“着色器”
    我想我快找到了
  • 这让我走得更近了,但仍然迷失了方向:
    • phantomjs.injectJs('C:/casperjs/module/bin/bootstrap.js')
      • 在C:/package.json中找不到package.json的
        错误
    • 好的,看起来我可以在启动phantomjs时传递--casper路径选项(请参阅-casper/bin/bootstrap.js:line 189)
    • 好的,那就行了。(传递选项不起作用,但在phantom内设置路径起作用)

因此,要让这些东西在phantomjs shell中运行,首先需要在phantomjs全局对象中设置一个
casperPath
变量

phantom.casperPath=“C:/casper”

然后需要插入caspers的
bootstrap.js
文件

phantom.injectJs(“C:/casper/bin/bootstrap.js”)

现在您可以实例化casper对象并在shell中使用它

var casper=require(“casper”).create()


享受。

不再有效。看看这个,这对我不管用。phantomjs 1.9.8不再具有casperPath变量。2016年是否有任何解决方案可以与casper-1.1.1和phantomjs 1.9.1建立交互模式?