今年的双11又到了,其中有个游戏挺无脑,就是不断的点猫来获取喵币,我写了个程序帮助我自动撸猫。为了不被后台检测到,我对点击的速度和点击的位置做了一定的随机变动。也正因为加了这点随机性,所以程序看起来稍有些复杂。
# 猫猫坐标544,1201 import os import time import random import re def click(position): shell = f"adb shell input tap {position[0]} {position[1]}" os.system(shell) base_sr = (1080, 2242) base_bn1 = (544, 1201) # 猫猫坐标 def get_resolution(): p = os.popen("adb shell wm size") result = p.read() pat = r'\d+' resolution = re.findall(pat, result) s = tuple([int(i) for i in resolution]) return s def coor_cover(old_resolution, old_coor, new_resolution): return round(new_resolution[0]*old_coor[0]/old_resolution[0]), \ round(new_resolution[1]*old_coor[1]/old_resolution[1]) current_sr = get_resolution() if current_sr == base_sr: current_bn1 = base_bn1 else: current_bn1 = coor_cover(base_sr, base_bn1, current_sr) while True: n = random.randint(1,200) # 因为人不可能一直点屏幕,所以加点延迟,以防被检查到作弊 time.sleep(random.random()*0.1) #随机小暂停 if n== 7: print("开始短暂停") time.sleep(random.randint(1,10)) # 随机大暂停 elif n == 11: print("开始长暂停") time.sleep(100) # 随机修改下位置,以免每次都点一个地方 position = (current_bn1[0]+ random.randint(-10,10), current_bn1[1] + random.randint(-10,10)) click(position)
其实很简单的,你学会了吗?
PS:如有需要Python学习资料的小伙伴可以加点击下方链接自行获取