用cheerio模拟按钮点击[node.js]

时间:2014-08-16 23:07:08

标签: node.js web-scraping imagebutton cheerio

任何人都可以指导我如何用cheerio模拟按钮点击吗?

按钮是图像按钮。点击后如何处理__dopostback

感谢

编辑:我正在尝试以下代码

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


})

0 个答案:

没有答案