dimanche 6 septembre 2015

javascript for and if-else statements (in CasperJS)

I'm crawling multiple page using CasperJSbut I got stucked.

The maximum number of pages are 200 but in case of "there is no page before 200th" I want to stop and escape for statement! == when there is no Xpath below

How can I set up "i" variable..??

for (var i=1; i <=200; i++) {
    casper.wait(6000, function() {

    casper.thenClick(x('//*[@id="mArticle"]/div[2]/a['+i+']'), function (){

        console.log('Searching dic');
        words = words.concat(this.evaluate(getWords));
        });

    });

Aucun commentaire:

Enregistrer un commentaire