我想在我的脚本中多次调用casper.start()
。
我已经尝试过:
var ids = [1,6,13];
ids.forEach(function(id) {
casper.start('http://localhost/mypage?id='+id, function() { });
});
casper.then(function() {
....
但是,只有最后一个 id 被执行。
可以多次调用casper.start()
吗?如果是这样,怎么办?
最佳答案
start()
只能对一个 casper
对象调用一次。您只会看到一次调用,因为对 start()
的第二次调用会重置内部状态。您可以使用thenOpen()
打开多个页面:
var ids = [1,6,13];
casper.start();
ids.forEach(function(id) {
casper.thenOpen('http://localhost/mypage?id='+id, function() {
this.capture("id.png");
});
});
casper.run();
关于javascript - 如何多次调用 casper.start(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33987621/