我必须使用Node JS发送以下POST请求。
POST /login.html HTTP/1.1
Host: 20.20.2.11
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:48.0) Gecko/20100101 Firefox/48.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://20.20.2.11/login.html
Connection: close
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 133
buttonClicked=4&err_flag=0&err_msg=&info_flag=0&info_msg=&redirect_url=&network_name=Guest+Network&username=f2015764&password=p4asword
但是以下Node JS代码不起作用
var request = require('request');
request.post({
headers: {'content-type' : 'application/x-www-form-urlencoded'},
url: 'https://20.20.2.11/login.html',
body: 'buttonClicked=4&username=f2015764&password=haXor21*'
}, function(error, response, body){
console.log(body);
});