作者:青岛大学MBA校友件_176 | 来源:互联网 | 2023-09-13 16:25
原标题:1、python连接手机自动搜集蚂蚁森林能量
1、python连接手机自动搜集蚂蚁森林能量
1、文章来源地址38270.html首先我们需要下载一个ADB DRIVER INSTALL驱动安装。需要的可以到我的资源那里下载
2、手机进入开发者模式,usb调试下面选择“仅为充电” 开始调试,插入usb线,手机把(usb调试)打开
3、之后进入刚刚下载的文件里面,比如我的就是:
C:\Users\18902\Downloads\platform-tools>
然后输入:python -m uiautomator2 init
这个步骤其实就是在我们的手机上安装apk。记住要去手机操作同意安装
4、这些东西都配置好之后我们需要到pycharm里面安装uiautomator2库。下面是一个镜像安装链接
pip install --upgrade uiautomator2 -i https://pypi.tuna.tsinghua.edu.cn/simple
5、之后便是代码实现啦!
import uiautomator2 as u2
import time
import random
d=u2.connect()
d.app_start("com.eg.android.AlipayGphone")
time.sleep(4)
print("打开蚂蚁森林,等待5s……")
d(text="蚂蚁森林").click()
time.sleep(5)
def cwww.yii666.comollectEnergy(cnt):
print("开始第%d次偷能量:"%cnt)
for x in range(150,1000,150):
for y in range(600,900,150):
d.long_click(x+random.randint(10,20),y+random.randint(10,20),0.1)
time.sleep(0.01)
if cnt!=1:
www.yii666.com d.click(536,1816)
cnt文章来源地址38270.html=1
while True:
collectEnergy(cnt)
a = d.xpath("//*[@resource-id='J_tree_dialog_wrap']").get().bounds
d.click(1000, a[3] - 80)
if d.xpath('//*[@text="返回我的森林"]').click_exists(timeout=2.0):
break
cnt+=1
print("###结束###")
6、运行测试
视频好像上传不文章来源站点https://www.yii666.com/了!!!
天呐!真实太棒啦!!!每次总是看到支付宝提示谁谁谁又来偷能量了。这次都不用我自己手动收能量了!!!大家快动手试起来哈哈哈哈
来源于:1、python连接手机自动搜集蚂蚁森林能量