在phantomjs中的控制台上打印XML文件

时间:2015-09-18 12:08:28

标签: phantomjs

我想在我的控制台上打印以下xml文件:

https://wpcom-themes.svn.automattic.com/demo/theme-unit-test-data.xml

这是我使用的脚本:

var page = require("webpage").create(),
url = "https://wpcom-themes.svn.automattic.com/demo/theme-unit-test-data.xml";

function onPageReady() {
var htmlContent = page.evaluate(function () {
    return document.documentElement.outerHTML;
});

console.log(htmlContent);

phantom.exit();
}

page.open(url, function (status) {
function checkReadyState() {
    setTimeout(function () {
        var readyState = page.evaluate(function () {
            return document.readyState;
        });

        if ("complete" === readyState) {
            onPageReady();
        } else {
            checkReadyState();
        }
    });
}

checkReadyState();
});

这是我得到的输出:

<html><head></head><body></body></html>

然后我将网址更改为http://www.google.com它工作正常。 知道我错过了什么吗?

0 个答案:

没有答案
相关问题