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/”>。 最好在头部,在'<head>'上replacestring,并用'<head> <base href =“http://google.com/”>'
让客户端获取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>
- 通过套接字连接将https代理请求pipe道传输到命名pipe道(node.js)
- 采用直接代理模式的McAfee Web Gateway后面的NodeJS(不透明)
- 节点unit testing – TypeError:无法读取未定义的属性“顺序”
- 如何使websockets在node.js中通过代理
- EC2托pipe了Node.js应用程序 – 无法远程连接到端口
- 带有代理类的TypeError – types错误:代理中的“set”:陷阱为属性返回truish
- npm install – >隧道套接字无法build立
- 简单的node.js代理通过http服务器http请求
- 如何在Node中代理媒体stream?