上创建通过不同的行动CasperJS一个简单的循环来我有此脚本如何
var i=0;
casper.start('http://www.example.com');
casper.then(function() {
this.sendKeys('#search_field', i);
this.click('input.vtop')
});
casper.then(function() {
description = this.fetchText('h2').trim();
description_longue = this.fetchText('#parent-longtext-body').trim();
price = this.fetchText("td.nowrap strong").trim();
})
casper.then(function() {
this.capture('site'+'i'+'.png');
});
casper.viewport(1024, 768);
casper.run();
我想我循环从0到5。我该怎么办呢? 简单for(i=0;i<5;<++)
不起作用!
一个简单的循环在CasperJS中工作得很好。它只是你想达到的目标。 –