如何在phantomjs shell中运行casper? [英] How do I run casper from within the phantomjs shell?

查看:75
本文介绍了如何在phantomjs shell中运行casper?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道是否以及如何在phantomjs shell中运行casperjs(又名 InteractiveModeREPL )?

Anyone know if and how it's possible to run casperjs from within the phantomjs shell (a.k.a InteractiveModeREPL )?

我也尝试过将直接路径传递给casper.js模块,但这也不起作用.

I've also tried passing the direct path to the casper.js module and that has not worked either.

进度/更新:

  • 尝试了phantomjs.injectJs('C:/casperjs/module/casper.js');但得到了Error: Cannot find module 'colorizer'我想我越来越近了.
  • 这使我更接近但仍然缺少路径:
    • phantomjs.injectJs('C:/casperjs/module/bin/bootstrap.js')
      • 使用Cannot find package.json at C:/package.json
      • 出错
      • Tried phantomjs.injectJs('C:/casperjs/module/casper.js'); but got Error: Cannot find module 'colorizer' I guess I'm getting close.
      • This gets me closer but still missing path:
        • phantomjs.injectJs('C:/casperjs/module/bin/bootstrap.js')
          • errors out with Cannot find package.json at C:/package.json

          推荐答案

          因此,要首先使这些内容在phantomjs shell中运行,您需要在幻像全局对象中设置一个casperPath变量.

          So to get this stuff to run inside the phantomjs shell first you need to set a casperPath variable in the phantom global object.

          phantom.casperPath = "C:/casper";

          然后,您需要注入caspers的bootstrap.js文件.

          Then you need to inJect caspers's bootstrap.js file.

          phantom.injectJs("C:/casper/bin/bootstrap.js");

          现在,您可以实例化一个casper对象并在外壳中使用它.

          Now you can instantiate a casper object and play with it in the shell.

          var casper = require("casper").create();

          享受.

          这篇关于如何在phantomjs shell中运行casper?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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