• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

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

python 搞代码 4年前 (2022-01-09) 21次浏览 已收录 0个评论
文章目录[隐藏]

工具准备

  • Python3.7.7
  • adb(Android debug bridge)
  • uiautomatorviewer

安装adb

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

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

安装uiautomatorviewer

参照此篇文章:https://www.cnblogs.com/corsacsherry/p/10609339.html

调试工具

  • 手机通过USB连接到电脑上开启开发者选项和USB调试
  • 在电脑上通过adb devices -l命令查看已连接的设备
  • 打开UIAutomatorViewer连接手机即可

Python安装uiautomator2

pip install --pre -U uiautomator2

给设备安装atx-agent

python -m uiautomator2 init

注意打开设备,允许uiautomator.apk的安装
参考连接:https://blog.gaodaima.com/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()description :a(description=”…”).click()

import uiautomator<strong>本文来源gaodaima#com搞(代@码$网6</strong>2 as d
import time
def douyin():
    #通过usb连接
    a=d.connect_usb('3d51a18c')
   	# 打开抖音
    a(text="抖音极速版").click()
    while True:
        time.sleep(10)
    	# 滑动视频
        a.swipe(313,1370,313,110)

if __name__=='__main__':
    douyin()

点击运行即可

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


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Python+uiautomator2实现自动刷抖音视频功能
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址