当前位置:网站首页>30行代码实现微信朋友圈自动点赞

30行代码实现微信朋友圈自动点赞

2022-08-09 12:23:00 xindoo

首先祝大家新年快乐,过年了,允许我水一篇博客。不知道大家都回老家了没,不过我是没有回去,晚上吃完年夜饭看到很多人发朋友圈,为了增进和大家的友谊,于是就想着给大家点个赞,无奈内容太多了,就搞个自动化脚本,原理和前两天我写的30行代码实现蚂蚁森林自动偷能量一样,这里不再赘述,直接上代码。


import uiautomator2 as u2
import time
# d = u2.connect()
d = u2.connect("192.168.0.102")

# d.app_start("com.tencent.mm")
# time.sleep(0.3)
# d(text="发现").click()
# time.sleep(0.3)
# d(text="朋友圈").click()

def click(): 
    time.sleep(0.2)
    d.xpath("//*[@resource-id='com.tencent.mm:id/kn']").click()
    time.sleep(0.2)
    if d.xpath("//*[@text='赞']").exists:
        time.sleep(0.2)
        d(text="赞").click()
        time.sleep(0.1)
        return True
    time.sleep(0.3)
    return False

def swipeDown():
    a = d.xpath("//*[@resource-id='com.tencent.mm:id/kn']")
    y = a.get().bounds
    dist = y[3]
    if dist < 200:
        dist = 220
    d.swipe(300, dist, 300, 50, 0.2)
    time.sleep(0.1)
    
cnt = 0
while True:
    if d.xpath("//*[@text='5小时前']").exists:
        break
    if click() == False:
    	cnt = cnt + 1 
    if cnt > 2:
        break
    swipeDown()

原网站

版权声明
本文为[xindoo]所创,转载请带上原文链接,感谢
https://xindoo.blog.csdn.net/article/details/113791863