查询nodejs

时间:2016-10-25 11:07:52

标签: javascript node.js http request.querystring

我的网址:

http://abcde.com/result.aspx?q=(some%20name%20here%20):Done&p=1&pos=0&qType=2

它在邮递员工作,也在curl命令工作。如果我在nodejs代码中尝试这个

var http = require("http");

var options = {
  "method": "GET",
  "hostname": "abcde.com",
  "port": null,
  "path": "/result.aspx?q=(some%2520name%2520here%2520)%3ADone&p=1&pos=0&qType=2",
  "headers": {
    "cache-control": "no-cache",
    "postman-token": "8e755cba-5d19-446f-269e-e880bd8cd7e1"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();

它不起作用。我认为,问题是查询参数中的一些特殊字符。任何人都知道如何解决这个问题。

0 个答案:

没有答案