Node.js http.get

我有以下代码请求Google.com主页,并将页面数据发送回客户端的Iframe。

var options = { host: 'www.google.com', port: 80, path: '/', method: 'GET' }; var req = http.get(options, function(res) { var pageData = ""; res.setEncoding('utf8'); res.on('data', function (chunk) { pageData += chunk; }); res.on('end', function(){ response.send(pageData) }); }); 

但是,所有的图像和CSS在iframe中被破坏? 我怎样才能保存图像和CSS?

最简单的解决scheme是向html添加<base href =“http://google.com/”>&#x3002; 最好在头部,在'<head>'上replacestring,并用'<head> <base href =“http://google.com/”>&apos;

让客户端获取Google页面不是更容易吗?

 <html> <head> <script> window.onload = function () { var nif = document.createElement("iframe"); nif.width = 850; nif.height = 500; nif.src = "http://www.google.de"; nif.appendChild( document.createTextNode("no iframe support") ); document.body.appendChild(nif); }; </script> </head> <body> <h1>IFRAME</h1> </body> </html>