无法创建线程管道:CasperJS上打开的文件太多

时间:2014-09-20 13:59:47

标签: javascript error-handling phantomjs casperjs

我制作了一个CasperJS脚本来从多个链接中获取所有图像。当我运行它时,它会工作几分钟,然后它就会抛出这个错误。

我不知道如何解决这个问题。

我的CasperJS脚本:

casper.repeat(200, function() {
    casper.thenOpen('http://google.fr/', function() { // Get a new page
        res = this.evaluate(function(wsurl) {
            return JSON.parse(__utils__.sendAJAX(wsurl, 'POST', null, false));
        }, {wsurl: ajax_url});
    });
    casper.then(function(){
        this.wait(1000);
    })
    casper.then(function(){
        this.open(res.source); // Open it
    });
    casper.then(function(){
        this.wait(1000);
    });
    casper.then(function(){
        arr_img = this.getElementsAttribute('img', 'src');
    });
    casper.then(function(){
        arr_img.forEach(function(value, key){ // Grab the images
            var img = new Image();
            img.src = value;
            if(img.width >= 337){
                temp  = {};
                temp['image']  = value;
                temp['width']  = img.width;
                temp['height'] = img.height;
                arr.push(temp);
            }
            delete window.img;
        });
    });
    casper.then(function(){
        require('utils').dump(arr);
        // Save the array
    });
    casper.then(function(){
        this.clear();
    });
});

我的错误:

QEventDispatcherUNIXPrivate(): Unable to create thread pipe: Too many open files
2014-09-20T15:37:27 [FATAL] QEventDispatcherUNIXPrivate(): Can not continue without a  thread pipe
Abort trap: 6

0 个答案:

没有答案
相关问题