首页 > casperjs 在nodejs下执行会出去卡住的情况,如何解决?

casperjs 在nodejs下执行会出去卡住的情况,如何解决?

google了半天也没找到如何解决~~~~ 希望有人能够解决
抓若干页面的时候,不知道什么时候抓取页面会出现卡住的情况,我查了进程,

我用ps -ef | grep phantomjs 查出的进程,发现

501 21887 21457 0 2:58下午 ttys015 0:00.83

这里的cpu执行时间不断的增加,我怀疑是压根没有执行我的脚本命令,因为我的casperjs里有 onwaitTimeout监听超时的事件,所以想知道大家有遇到这种情况吗?

以下是我的casper脚本:

var fs = require('fs');
var casper = require('casper').create({
    clientScripts: [
        'include/jquery.js', // These two scripts will be injected in remote
    ],
    pageSettings: {
        loadImages: false, // The WebPage instance used by Casper will
        loadPlugins: false // use these settings
    },
    logLevel: "info", // Only "info" level messages will be logged
    verbose: false, // log messages will be printed out to the console
    stepTimeout:10000,
    viewportSize:{width: 1280, height: 768},
    onWaitTimeout:function(){
        this.echo('-----output-----timeout-----output end-----','Info');
    }
});

casper.userAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36');
var content = {};
var address = casper.cli.get(0);

casper.start(address);

casper.waitForSelector(".detail-info", function() {
    this.echo('-----output-----' + this.evaluate(function() {
        return $('.brief a').attr('href');
    }) + '-----output end-----', 'INFO'); // Will be printed in green on the console
});


casper.then(function(){
    this.captureSelector('twitter2.png', 'html');
})

casper.run();
【热门文章】
【热门文章】