通常在 购物网站 会遇到各种抢购 商品,奈何手速跟不上,这就需要自己写个脚本 来试试啦!!
原理:不管是抢购什么商品,都是一个原理 我们快速的点击下单按钮或者确认按钮来跳到支付页面,进行结算,所以有时候我们明明看着时间差不多点的 或者 到点 秒点击 还是会发现抢不到,所以这个是时候就可以试一下脚本。
1. 首先 需要来一个倒计时确认的方法 来保证和网站时间同步。
function CurentTime()
{
var now = new Date();
var year = now.getFullYear(); //年
var month = now.getMonth() + 1; //月
var day = now.getDate(); //日
var hh = now.getHours(); //时
var mm = now.getMinutes(); //分
var ss =now.getSeconds() //秒
clock = year + "-";
if(month < 10)
clock += "0";
clock += month + "-";
if(day < 10)
clock += "0";
clock += day + " ";
if(hh < 10)
clock += "0";
clock += hh +":";
if (mm < 10)
clock += '0';
clock += mm+":";
if (ss < 10)
clock += '0';
clock += ss;
//return(clock);
console.log(clock)
}
2. 好了有了这个方法就可以确保时间是同步的了,接下来获取元素,写个定时器直接请求就ok了。
var btnObj =$('.product-button02') //举例 根据自己实际情况填写
console.log(btnObj)
var timer=setInterval(function(){
CurentTime()
if (clock=='2021-08-09 16:00:50') { // 当按钮可以点击时
btnObj.click(); //点击
// clearInterval(timer); // 选购完成后关闭timer,否则将一直购买,土豪随意
}else{
console.log('4444')
}
},1000)
3. 脚本写好以后,直接打开网站console(按f12可直接进入)直接回车运行就好了。