系列文章目录
文章目录
目录
前言
Python是很好的脚本语言,可以完成很多自动化测试方面的工作。本文介绍以下自动刷抖音赚钱。
一、实现思路
为了模拟人为刷抖音,需要模拟上划操作,这里使用到了adb shell input swipe。实现这个命令之前需要满足两个条件。第一个电脑上必须安装好adb,用usb或者网络连接好手机。在命令下输入
adb devices,确认adb连接是否正确,正常连接手机的话会显示类似以下内容。具体adb的使用方法可以在网上找到。
List of devices attached
0123456789ABCDEF device
input swipe模拟的是滑动事件,input swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen),需要将起始的坐标传进去。
input swipe 600 800 300 800 将会向左滑动。
二、基本操作
1.实现自动刷视频的函数
def shuashipin():
x1=random.randint(355,360)
y1=random.randint(100,120)
x0=random.randint(355,360)
y0=random.randint(980,1000)
command='adb shell input swipe %d %d %d %d 1000' % (x0,y0,x1,y1)
print(command,flush=True)
os.system(command)
tm=random.randint(10,30)
print(tm,flush=True)
time.sleep(tm)
为了防止封账户,上划的坐标使用了随机数,更好的模拟人的行为。
2.进阶
打开抖音app软件
adb shell am start -n com.ss.android.ugc.aweme.lite/com.ss.android.ugc.aweme.main.MainActivity
为了防止手机被其他软件打断,还需要判断当前运行的是不是在抖音界面,不是抖音界面的时候,可以用adb shell am start重新切换到抖音界面。