如何使用http模块通过查询字符串和Cookie发出GET请求?
GET someurl?test=one
Cookies:name = john; NAME1 =玛丽;
答案 0 :(得分:0)
var http = require('http');
var url_parser = require("url");
var url = "someurl?test=one";
var url_parts = url_parser.parse(url);
var options = {host: url_parts.hostname, port: url_parts.port|80, path: url_parts.path};
var request = http.request(options, function(response) {
//do something with the response
}).on('error',function(e){
//error happened
});
request.setHeader( 'cookie', YOUR_COOKIE );
request.end();