How to use node to simulate Baidu login? I can’t get through all the tests. I’ve shared some of them with you ~

  node.js, question

Two reference articles ~ hope to help those familiar with node ~ use node-webkit to make a tool to simulate Baidu login

C# Simulates Baidu Landing
http://www.51joben.com/archives/7151.html

Php Simulates Baidu Login
http://www.qaulau.com/php-simulated-login-baidu/

Request

Simulate login is simply to simulate sending http requests

exports.sendEmail = function (req, res) {
 
 var data = {
 address: 'test@test.com',
 subject: "test"
 };
 
 data = require('querystring').stringify(data);
 console.log(data);
 var opt = {
 method: "POST",
 host: "localhost",
 port: 8080,
 path: "/v1/sendEmail",
 headers: {
 "Content-Type": 'application/x-www-form-urlencoded',
 "Content-Length": data.length
 bracket
 };
 
 var req = http.request(opt, function (serverFeedback) {
 if (serverFeedback.statusCode == 200) {
 var body = "";
 On ('data', function (data) {body plus = data;  })
 .on('end', function () { res.send(200, body);   });
 bracket
 else {
 res.send(500, "error");
 bracket
 });
 Req.write(data plus "\n");
 req.end();
 bracket

The above is a function I originally wrote. You can refer to the following
Note that the user’s cookie should be written to headers when simulating login.