too*_*oom 11 html web-crawler phantomjs
我刚刚下载并在我的机器上安装了phantomjs.我将以下脚本复制并粘贴到名为hello.js的文件中:
var page = require('webpage').create();
var url = 'https://www.google.com'
page.onLoadStarted = function () {
console.log('Start loading...');
};
page.onLoadFinished = function (status) {
console.log('Loading finished.');
phantom.exit();
};
page.open(url);
Run Code Online (Sandbox Code Playgroud)
我想将完整的HTML源(在本例中是从谷歌页面)打印到文件或控制台.我该怎么做呢?
Ari*_*yat 50
花了一些时间阅读文档,之后应该是显而易见的.
var page = require('webpage').create();
page.open('http://google.com', function () {
console.log(page.content);
phantom.exit();
});
Run Code Online (Sandbox Code Playgroud)