How to get asp.net hidden fields values ​​using node js?

I am trying to log into a site with nodejs

. The login form asp.net

has hidden fields: __EVENTTARGET, __EVENTVALILDATION, __VIEWSTATE, __EVENTARGUMENT

I am trying to execute the following code:

process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0'; // Ignore 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' authorization error

var request = require('request');
var cheerio = require('cheerio');

function postback(url, callback) {
    request.get(url, function onResponse(err, res, body) {
        $ = cheerio.load(body);
        var button = callback(err, $);
        if (button) {
            var form = {
                //__EVENTTARGET: button.attr('form1').match(/['"]([^"^']+)/)[0], // TODO image buttons
                __EVENTTARGET: button.attr('Button1'),
                __VIEWSTATE: $('#__VIEWSTATE').val(),
                __EVENTVALIDATION: $('#__EVENTVALIDATION').val(),
                __EVENTARGUMENT: $('__EVENTARGUMENT').val(),
            };
        }
    });
}

postback('https://example.com', function(err, $) {
    var button=$('input[type="image"]');
    return button
    //console.log(err)
    //console.log($)
})

      

It doesn't get meaning __EVENTTARGET

and __EVENTARGUMENT

. These fields may require a button click. How to click on it with cheerio?

+3


source to share





All Articles