var http=require( 'http' ); http.get( 'http://baidu/dksapi/weiboLive/GetSquareLive?pagecount=1&pageindex=1&source=0' , function (response) { var rawContent= '' ; response.on( 'data' , function (chunk) { rawContent+=chunk.toString(); }) response.on( 'end' , function () { res.send(rawContent); }) }) |
router.get('/', function(req, res, next) { var post_data={username:'yuzhou001',password:'123456'};//这是需要提交的数据 var content=qs.stringify(post_data); var options = { host: 'www.badiu.cn', port: 80, path: '/api/User/Login', method: 'POST', headers:{ 'Content-Type':'application/x-www-form-urlencoded', 'Content-Length':content.length } }; var req = http.request(options, function(res) { /* console.log("statusCode: ", res.statusCode); console.log("headers: ", res.headers);*/ var _data=''; res.on('data', function(chunk){ _data += chunk; }); res.on('end', function(){ console.log(" --->> result:",_data); pages(_data); }); }); req.write(content); req.end(); function pages(datas) { res.send(datas);//返回页面数据,闭包 }