Problem sending POST
mrcanelas opened this issue · comments
Hello everyone, can anyone with experience with the needle module give me a light? I need to log in to a web page and this login is done through a POST, take the cookies from the login page to the download page for the download to be authorised, my code seems all right, but when I run it needle sends a GET instead of a POST.
const data = "data%5BUser%5D%5Busername%5D=pipoca-filmes&data%5BUser%5D%5Bpassword%5D=pipocafilmes&data%5Blembrar%5D=on";
const loginEndpoint = "http://legendas.tv/login";
const options = {
headers: {
"Content-Length": data.length,
"Content-Type": "application/x-www-form-urlencoded",
},
follow_max: 9,
};
const sub = "http://legendas.tv/downloadarquivo/609dcd2468d08/";
needle.post(loginEndpoint, data, options, function (error, response) {
if (!error && response.statusCode == 200) console.log(response);
needle.get(sub, { follow_set_cookies: true }, function (error, res) {
if (!error && res.statusCode == 200) console.log(res);
});
});
Response:
_headerSent: true, socket: [Circular *1], _header: 'GET / HTTP/1.1\r\n' + 'accept: */*\r\n' + 'user-agent: Needle/2.6.0 (Node.js v14.15.3; win32 x64)\r\n' + 'content-type: application/x-www-form-urlencoded\r\n' + 'host: legendas.tv\r\n' + 'Connection: close\r\n' + '\r\n', _keepAliveTimeout: 0,