基于airtest的朋友圈自动点赞

本脚本可以通过AirtestIDE和python执行,推荐使用AirtestIDE的环境执行,更稳定一些
AirtestIDE官方文档

使用python执行该脚本
安装库 airtest、pocoui

pip install airtest
pip install pocoui

代码如下

# -*- encoding=utf8 -*-
__author__ = "admin"
from airtest.core.api import *
from poco.drivers.android.uiautomation import AndroidUiautomationPoco

poco = AndroidUiautomationPoco(use_airtest_input=True, screenshot_each_action=False)
connect_device("Android://127.0.0.1:5037/f350e2f7")
print("start...")
PKG = "com.tencent.mm"  # 微信包名
stop_app(PKG)  # 关闭此app
wake()  # 唤醒并解锁设备
home()  # 返回HOME界面
start_app(PKG)  # 启动此app

poco(text='发现').wait(2).click()
pyq = poco(text='朋友圈')
pyq.click()

while True:
    try:
        # 评论按钮
        comments = poco("com.tencent.mm:id/eho")
        for comment in comments:
            childX, childY = comment.get_position()
            print(childX)
            print(childY)
            if (childY >= 0.1 and childY < 1.0):
                comment.click()
                zan = poco(text='赞')
                if zan.exists():
                    zan.click()
    except Exception as e:
        print('error'+str(e))
        keyevent("BACK")  # 有可能进入其它页面,调用系统级返回按钮
        if pyq.exists(): # 如果返回到发现页,重新进入朋友圈
            pyq.click()
    swipe((500, 1700), (500, 900))  # 向上滑动

来源于https://blog.csdn.net/qq_38534107/article/details/93232179

原文地址:https://www.cnblogs.com/hankleo/p/11264850.html