Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Phantomjs无法使用render_multi_url.js呈现url_Phantomjs - Fatal编程技术网

Phantomjs无法使用render_multi_url.js呈现url

Phantomjs无法使用render_multi_url.js呈现url,phantomjs,Phantomjs,我有这个phantomjs代码,这应该可以将url中的内容呈现/保存到pdf文件中 在代码末尾,我有一个数组: arrayOfUrls = ["http://192.168.0.49/a/view/id/6", "http://192.168.0.49/a/view/id/5", "http://192.168.0.49/a/view/id/4"]; 错误是: 无法渲染'http://192.168.0.49/a/view/id/6“ 无法渲染'http://192.168.0.49/a/vi

我有这个
phantomjs
代码,这应该可以将url中的内容呈现/保存到pdf文件中

在代码末尾,我有一个数组:

arrayOfUrls = ["http://192.168.0.49/a/view/id/6", "http://192.168.0.49/a/view/id/5", "http://192.168.0.49/a/view/id/4"];
错误是:

无法渲染'http://192.168.0.49/a/view/id/6“
无法渲染'http://192.168.0.49/a/view/id/5“
无法渲染'http://192.168.0.49/a/view/id/4“

// Render Multiple URLs to file

var RenderUrlsToFile, arrayOfUrls, system;

system = require("system");

/*
Render given urls
@param array of URLs to render
@param callbackPerUrl Function called after finishing each URL, including the last URL
@param callbackFinal Function called after finishing everything
*/
RenderUrlsToFile = function(urls, callbackPerUrl, callbackFinal) {
    var getFilename, next, page, retrieve, urlIndex, webpage;
    urlIndex = 0;
    webpage = require("webpage");
    page = null;
    getFilename = function() {
        return "rendermulti-" + urlIndex + ".pdf";
    };
    next = function(status, url, file) {
        page.close();
        callbackPerUrl(status, url, file);
        return retrieve();
    };
    retrieve = function() {
        var url;
        if (urls.length > 0) {
            url = urls.shift();
            urlIndex++;
            page = webpage.create();
            page.viewportSize = {
                width: 800,
                height: 600
            };
            page.settings.userAgent = "Phantom.js bot";
            return page.open("http://" + url, function(status) {
                var file;
                file = getFilename();
                if (status === "success") {
                    return window.setTimeout((function() {
                        page.render(file);
                        return next(status, url, file);
                    }), 200);
                } else {
                    return next(status, url, file);
                }
            });
        } else {
            return callbackFinal();
        }
    };
    return retrieve();
};

arrayOfUrls = null;

if (system.args.length > 1) {
    arrayOfUrls = Array.prototype.slice.call(system.args, 1);
} else {
    console.log("Usage: phantomjs render_multi_url.js [domain.name1, domain.name2, ...]");
    arrayOfUrls = ["http://192.168.0.49/a/view/id/6", "http://192.168.0.49/a/view/id/5", "http://192.168.0.49/a/view/id/4"];
}

RenderUrlsToFile(arrayOfUrls, (function(status, url, file) {
    if (status !== "success") {
        return console.log("Unable to render '" + url + "'");
    } else {
        return console.log("Rendered '" + url + "' at '" + file + "'");
    }
}), function() {
    return phantom.exit();
});

您需要像这样编写URL

arrayOfUrls = ["192.168.0.49/a/view/id/6", "192.168.0.49/a/view/id/5", "192.168.0.49/a/view/id/4"];
没有“http://”