我正在尝试使用 phantomjs 为以下文件解析 xml,documentpreviewer1.js
var webPage = require('webpage');
var page = webPage.create();
var url = "http://xxx/sitemap.xml";
page.open(url, function(status){
if(status != 'success'){
console.log('Unable to access cfc');
}
else
{
var xml = page.content;
var libxmljs = require("libxmljs");
var xmlDoc = libxmljs.parseXml(xml);
var url1 = xmlDoc.get('//urlset/url[0]/loc');
console.log(url1);
}
});
当我运行上面的代码时,我收到以下错误
命令sudo phantomjs documentpreivewer1.js
Error: Cannot find module 'libxmljs'
phantomjs://bootstrap.js:289
phantomjs://bootstrap.js:254 in require
documentpreivewer1.js:13
:/modules/webpage.js:281