//http://qson.iteye.com/blog/2055523
//var http=require("http");
//http.get("http://h5.hejian.com/index.html", function(res) {
//console.log("Got response: " + res.statusCode);
//}).on('error', function(e) {
//console.log("Got error: " + e.message);
//});
//http://blog.csdn.net/wmsjlihuan/article/details/19481541
//var http=require('http');
//http.get("http://bananapi.ittun.com/http.php?name=test&pwd=123456", function(res) {
// console.log("Got response: " + res.statusCode);
// res.on('data', function(data) {
// console.log("Got data: " + data);
// });
// }).on('error', function(e) {
// console.log("Got error: " + e.message);
//});
//var http=require('http');
//var options = {
// host:'bananapi.ittun.com',
// port:80,
// path:'/http.php?name=test&pwd=1*****u'
// };
//http.get(options, function(res) {
// console.log("Got response: " + res.statusCode);
// res.on('data', function(data) {
// console.log("Got data: " + data);
// });
// }).on('error', function(e) {
// console.log("Got error: " + e.message);
// });
var http = require('http');
var qs = require('querystring');
var data = {
name: 123,
pwd: new Date().getTime() };//这是需要提交的数据
var content = qs.stringify(data);
var options = {
hostname: 'bananapi.ittun.com',
port: 80,
path: '/http.php?' + content,
method: 'GET'
};
var req = http.request(options, function (res) {
console.log('STATUS: ' + res.statusCode);
console.log('HEADERS: ' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('BODY: ' + chunk);
});
});
req.on('error', function (e) {
console.log('problem with request: ' + e.message);
});
req.end();