1.看到朋友圈抢周杰伦、林俊杰演唱会票贼难信息,特研究了一段时间,用autox.js写了自动化抢票脚本,购票页面自动点击下单(仅限安卓手机)。
2.脚本运行图
3.前期准备工作
(1)autox.js社区官网:AutoX.js
(2)b站上学习资料:10分钟学会AutoX.js hello world_哔哩哔哩_bilibili
AutoX.js控件操作_哔哩哔哩_bilibili
4.源码
// 检查无障碍服务是否已经启用,如果没有启用则跳转到无障碍服务启用界面,并等待无障碍服务启动;当无障碍服务启动后脚本会继续运行。auto.waitFor();//打开猫眼appapp.launchApp("猫眼");openConsole();console.setTitle("猫眼 go!","#ff11ee00",30);main();//获取输入的场次信息
function getPlayEtc(){var playEtc = rawInput("请输入场次关键字(按照默认格式)", "周六");if (playEtc == null || playEtc.trim()=='') {alert("请输入场次信息!");return getPlayEtc();}console.log("手动输入的场次信息:"+playEtc);return playEtc;
}//获取输入票价信息
function getTicketPrice(){var ticketPrice = rawInput("请输入票价关键字(按照默认格式)", "788");if (ticketPrice == null || ticketPrice.trim()=='') {alert("请输入票价信息!");return getTicketPrice();}console.log("手动输入的票价信息:"+ticketPrice);return ticketPrice;
}//获取输入的抢票时间
function getSellTime(){var sellTime = rawInput("请输入抢票时间(按照默认格式)", "10-07 12:18");if (sellTime == null || sellTime.trim()=='') {alert("请输入抢票时间!");return getSellTime();}return sellTime;
}]]}/*** * @returns 大麦服务器时间戳*/
function getDamaiTimestamp() {return JSON.parse(http.get("https://mtop.damai.cn/gw/mtop.common.getTimestamp/", {headers: {'Host': 'mtop.damai.cn','Content-Type': 'application/json;charset=utf-8','Accept': '*/*','User-Agent': 'floattime/1.1.1 (iPhone; iOS 15.6; Scale/3.00)','Accept-Language': 'zh-Hans-CN;q=1, en-CN;q=0.9','Accept-Encoding': 'gzip, deflate, br','Connection': 'keep-alive'}}).body.string()).data.t;
}/*** * @param {时间戳} timestamp * @returns ISO 8601 格式的北京时间*/
function convertToTime(timestamp) {var date = new Date(Number(timestamp));var year = date.getUTCFullYear();var month = (date.getUTCMonth() + 1).toString().padStart(2, "0");var day = date.getUTCDate().toString().padStart(2, "0");var hours = (date.getUTCHours() + 8).toString().padStart(2, "0");var minutes = date.getUTCMinutes().toString().padStart(2, "0");var seconds = date.getUTCSeconds().toString().padStart(2, "0");var milliseconds = date.getUTCMilliseconds().toString().padStart(3, "0");var iso8601 = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}.${milliseconds}`;return iso8601;
}//点击控件所在坐标
function btn_position_click(x) {if (x) {var b = x.bounds();print(b.centerX())print(b.centerY())var c = click(b.centerX(), b.centerY()) console.log("点击是否成功:"+c);}
}