好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

Python+uiautomator2实现自动刷抖音视频功能

工具准备

python3.7.7 adb(android debug bridge) uiautomatorviewer

安装adb

官网地址:https://developer.android.google.cn/studio/command-line/adb

下载好解压后设置环境变量即可

安装uiautomatorviewer

参照此篇文章:https://HdhCmsTestcnblogs测试数据/corsacsherry/p/10609339.html

调试工具

手机通过USB连接到电脑上开启开发者HdhCmsTestcppcns测试数据选项和USB调试 在电脑上通过 adb devices -l 命令查看已连接的设备

打开UIAutomatorViewer连接手机即可

Python安装uiautomator2

pip install --pre -U ui 编程客栈 automator2

给设备安装atx-agent

python -m uiautomator2 init

注意打开设备,允许uiaut 编程客栈 omator.apk的安装 参考连接:https://blog.csdn.net/plychoz/article/details/80231550

编写主程序

定位抖音位置

几种定位方式如下:

text:a(text=“抖音极速版”).click()resourceid:a(resourceId=“com.smartisanos.clock:id/text_stopwatch”).click()classname:a(className=“android.widget.TextView”).click( iKrlg )description :a(description="…").click()

import uiautomator2 as d
import time
def douyin():
    #通过usb连接
    a=d.connect_usb('3d51a18c')
   	# 打开抖音
    a(text="抖音极速版").click(http://HdhCmsTestcppcns测试数据)
    while True:
        time.sleep(10)
    	# 滑动视频
        a.swipe(313,1370,313,110)

if __name__=='__main__':
    douyin()

点击运行即可

到此这篇关于Python+uiautomator2实现自动刷抖音视频的文章就介绍到这了,更多相关Python自动刷抖音视频内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

查看更多关于Python+uiautomator2实现自动刷抖音视频功能的详细内容...

  阅读:43次