Python 实现自动刷抖音,解放双手了

前言

我不知道有没有像我这样的朋友,每次刷抖音都不想这么做。我希望有什么东西可以替代我的手指。我给它一个命令,它就会知道我想要什么。在……里面

[En]

I don’t know if there is a friend like me who doesn’t want to do it every time he browses Douyin. I wish there was something to replace my finger. I give it an order and it will know what I want. In

是,我利用空闲时间操作了一下,终于用Python把自动刷抖音给搞出来了,这下真的是解决了我长久以来的困扰…

工具准备

1.Python3.7.7

2.adb(Android debug bridge)

3.uiautomatorviewer

安装adb

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

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

[En]

After downloading and decompressing, you can set the environment variable.

调试工具

1.手机通过USB连接到电脑上开启开发者选项和USB调试

2.在电脑上通过adb devices -l命令查看已连接的设备

3.打开UIAutomatorViewer连接手机即可

Python 实现自动刷抖音,解放双手了

Python安装uiautomator2

pip install --pre -U uiautomator2

给设备安装atx-agent

python -m uiautomator2 init

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

; 编写主程序

定位抖音位置

Python 实现自动刷抖音,解放双手了

几种定位方式如下:

1.text:a(text="抖音极速版").click()

2.resourceid:a(resourceId="com.smartisanos.clock:id/text_stopwatch").click()

3.classname:a(className="android.widget.TextView").click()

4.description :a(description="...").click()
import uiautomator2 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()

点击运行即可~

最后

今天的分享到此结束。本文的代码非常简短,只用了14行。我不相信你学会不了这么短的密码。如果你学不会,我就认输。关闭

[En]

This is the end of today’s sharing. The code of this article is very short, using only 14 lines. I don’t believe you can’t learn such a short code. If you can’t learn it, then I throw in the towel. Off

于Python其他的问题可以私信我哟!!我看见就回复你,笔芯~~~

Original: https://www.cnblogs.com/1234567FENG/p/16363217.html
Author: 蚂蚁爱Python
Title: Python 实现自动刷抖音,解放双手了

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/499413/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球