nodejs怎么模拟登陆?
发布于 3个月前 作者 sfanr 407 次浏览 来自 问答

var http = require(“http”); var querystring = require(“querystring”);

var options = { hostname: '127.0.0.1’, port: 9000, path: '/modules/login/checkSign.php’, method: ‘POST’ }; var contents = querystring.stringify({ username: 'admin’, password: ‘123456’ }); var req = http.request(options, function(res) { res.setEncoding(‘utf8’); res.on('data’, function (data) { console.log(‘BODY:’ + data); }); });

req.on('error’, function(e) { console.log('problem with request: ' + e.message); });

req.write(contents); req.end(); 接收不到这里提交的参数呢?请各路大神指教一下!

3 回复

supertest npm or postman

options no headers

回到顶部