can anyone guide me how to simulate button click with cheerio?
the button is an image button. after click how to handle the __dopostback
?
THANKS
Edit: i am trying 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('Button1'),
__VIEWSTATE: $('#__VIEWSTATE').val(),
__EVENTVALIDATION: $('#__EVENTVALIDATION').val(),
__EVENTARGUMENT: $('__EVENTARGUMENT').val(),
user:'username',
pass: 'pasword',
};
request.post(url, {form: form }, onResponse);
}
});
}
postback('https://mysite.com', function(err, $) {
var button=$('input[type="image"]');
return button
})