我想做一个机器人,点击网页上的一个按钮。我已经用硒做过了,但是速度很慢,我需要快一点。所以我选择了请求库。我只是想问:你有没有办法按下一个按钮来处理请求? 网站:https://manomokykla.lrt.lt/mokyklos/(我只是在这个网站上测试,不打算用bot或其他方式)我只是想知道如何按下按钮,这样我可以在我未来的项目中使用它
以下是网站上的按钮:
按钮的功能:
function(event)
{
var school = $(this).data('school-id');
var ip = $('input[name="ip-address"]').val();
var current = $('div[data-mokyk-id="' + school + '"] strong').text();
var getCokies = Cookies.get('balsuok');
Cookies.set('balsuok', '1', {
expires: 30
});
if (getCokies !== undefined && getCokies == '1') {
} else {
var formData = {
'from': 'balsuok',
'school': school,
'ip': ip
};
$.ajax({
type: 'POST',
url: '/wp-content/themes/ism-lrt-promo/ajax/balsuok.php',
data: formData,
dataType: 'json',
encode: true
})
// using the done promise callback
.done(function(data) {
if (data['success'] == true) {
$('.popup-all-info-success').addClass('active');
$('.popup-all-info').removeClass('active');
setTimeout(function() {
$('.open-counter').show();
$('.action-line').removeClass('active');
$('.action-line').remove();
$('div[data-mokyk-id="' + school + '"] strong').html(parseInt(current) + 1);
$('div[data-mokyk-select="' + school + '"] span').attr('data-number-length', parseInt(current) + 1);
$('.line span').each(function(i, obj) {
var currentNumber = $(this).data('number-length');
var calculate = (currentNumber * 100) / getMaxNumber;
$(this).css('width', calculate + '%');
});
}, 1000);
}
})
.fail(function(data) {
console.log(data);
});
}
event.preventDefault();
}
投票后的参数:
目前没有回答
相关问题 更多 >
编程相关推荐