我目前从 CLI 运行CasperJS脚本,如下所示:
module Main where
pow :: Int -> Int -> Int
pow x 0 = 1
pow x y = x * pow x y-1
main :: IO ()
main = print( pow 2 3 )
..但要自动完成整个过程,我需要从另一个脚本中调用它作为模块/函数并传递参数(关键字等)。所以想知道最好的方法是什么。
答案 0 :(得分:0)
想通了。 Spooky!
var spooky = new Spooky({
casper: {
//configure casperjs here
}
}, function (err) {
// NODE CONTEXT
console.log('We in the Node context');
spooky.start('http://www.example.com
spooky.then(function() {
// CASPERJS CONTEXT
console.log('We in the CasperJS context');
this.emit('consoleWe can also emit events here.');
this.click('a#somelink });
spooky.then(function() {
// CASPERJS CONTEXT
var size = this.evaluate(function() {
// PAGE CONTEXT
console.log('....'); // DOES NOT GET PRINTED OUT
__utils__.echo('We in the Page context'); // Gets printed out
this.capture('screenshot.png');
var $selectsize = $('select#myselectlist option').size();
return $selectsize;
})
})