我有一个需要抓取的队列中的案例列表。你可以想象,它有点重复和耗时。我是编程新手,并没有找到一种方法来创建一个自动点击/抓住这些案例的脚本。有人可以帮忙吗?
代码: 1)搜索并点击“抓取” - 页面刷新需要4秒钟 2)再次点击抓取 3)抓住50个案件后停止
此代码不起作用
window.setTimeout("pushSubmit()",3000);
function pushSubmit()
{document.getElementById('Grab').click();
答案 0 :(得分:2)
假设您的页面在此过程中未刷新,您可以反击一下您已完成的“Grabs”数量:
var counter = 0;
var maxCount = 50;
function pushSubmit() {
if(counter++ < maxCount) {
document.getElementById('Grab').click();
window.setTimeout(pushSubmit,3000);
}
}
//start the process
pushSubmit();
修改强>
或者我可能更喜欢的是,设置函数以便它可以用于任意次数的迭代。
function pushSubmit(max, count) {
count = typeof count !== 'undefined' ? count : 1;
if(count <= max) {
document.getElementById('Grab').click();
window.setTimeout(function() { pushSubmit(max, ++count) },3000);
}
}
//start the process with the max number of iterations it should perform
pushSubmit(50);