此代码应从 html 页面加载数据。
var http = require('http');
http.get('http://www.google.com', onGotData);
function onGotData(res) {
var chunks = [];
res.on('data', onGotData);
res.on('end', onEnd);
function onGotData(chunk) {
chunks.push(chunk);
}
function onEnd() {
console.log(chunks.join(''));
}
}
Run Code Online (Sandbox Code Playgroud)