You need to log in to a third-party server and access the content for authorized users.
PhantomJS is not suitable.
I tried this:
var request = require('request'); var cheerio = require('cheerio'); var credentials = { username: 'user', password: 'pass' }; request.post({ uri: 'http://mysite.ru/login', headers: { 'content–type': 'application/x–www–form–urlencoded' }, body: require('querystring').stringify(credentials) }, function(err, res, body){ if(err) { callback.call(null, new Error(' Login failed')); return; } request('http://mysite.ru/all', function(err, res, body) { if(err) { callback.call(null, new Error('Request failed')); return; } var $ = cheerio.load(body); console.log(body); }); });
But at the output gives the HTML code of the same login page.
I do not ask to edit my code, but maybe someone will stick his nose at the correct lesson? Preferably in conjunction with PostMan - ohm (so that you can analyze the standard browser requests and use them in your requests from the application)