Answer the question
In order to leave comments, you need to log in
How to log in to a site using Node.js?
Good afternoon. I want to parse the site, but for this you need to register first
const request = require('request');
const cheerio = require('cheerio');
request('https://url.com', (error, response, body) => {
let $ = cheerio.load(body);
const __RequestVerificationToken = $('#signin input').attr('name', '__RequestVerificationToken').val();
const LoginUserName = '*****';
const LoginPassword = '****';
request.post(
{
url:'https://url.com/Login',
form: {
'__RequestVerificationToken': __RequestVerificationToken,
LoginUserName,
LoginPassword
}
},(err, httpResponse, body) => {
if (err) {
return console.error('Error:', err);
}
console.log('Body:', body);
})
});
Answer the question
In order to leave comments, you need to log in
Headlines, look there.
And also jar (cookie) - most likely it is also necessary to skip
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question