javascript - this.echo is not working in this.thenOpen -
javascript - this.echo is not working in this.thenOpen -
i wrote simple capserjs script based on casperjs - how open links in array of links , not print title.
var casper = require('casper').create(); var = -1; var links; casper.start('http://www.waspbarcode.com/barcode-scanners', function() { links = ['https://www.yahoo.com' , 'https://www.google.com' , 'http://stackoverflow.com'] }); casper.then(function() { this.each(links, function() { i++; this.thenopen(links[i], function() { this.echo(this.gettitle()); }); }); this.exit(); }); casper.run();
because did this.exit(); after trying open urls in links.
you need understand works asynchronously. programs exits after casperjs starts loading links 1 after other.
javascript web-scraping casperjs
Comments
Post a Comment