python+adb命令实现自动刷视频脚本案例


Posted in Python onApril 23, 2020

python小白第一次发博客,自己自学了一下写了一个demo,可能语法啥的不够标准,毕竟没有真正学过python

主要用到的是

import os #os包用于运行cmd命令
adb shell #这个有很多命令我们主要是模拟滑动

直接看代码吧

手机要先连接电脑打开usb调试模式

# _*_ coding:utf-8 _*_
#
# @Version : 1.0
# @Time : 2019/9/10
# @Author :wang

import os
import time
b = 0

def video: 
 fun=os.system('adb shell input swipe 300 600 300 100') ##坐标根据需要自己修改
 time.sleep(13)

if __name__ == '__main__':
 os.chdir("D:\\adb")   ##切换到adb所在目录可以自己修改
 print("已连接设备名称如下:")
 fun= os.system('adb devices')
 a=input('输入次数需要滑动的次数:')
 a=int(a)
  while b<a:
   video()  ##循环结构中调用函数
   b=b+1
   print("任务完成",b,"次")
  else:
   print("任务全部完成")
   fun=os.system('adb kill-server') ##运行结束杀掉adb进程
   exit()

文章到这就结束啦!!有需要的人可以拿去!

补充知识:使用pip安装pocoui

废话不多说,直接看代码!

adog@E531:~$ pip3 install pocoui -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
Collecting pocoui
 Downloading http://pypi.doubanio.com/packages/79/b7/0a097349da63681463f62680b01b987e91af5804d59b9fbb33798ae2c614/pocoui-1.0.76.tar.gz (2.6MB)
 100% |????????????????????????????????| 2.6MB 12.1MB/s 
Collecting airtest (from pocoui)
 Downloading http://pypi.doubanio.com/packages/b7/57/3547f040fced101ba57a2360b134940adb0865aa00e5d1bc2b64750fb15f/airtest-1.0.27.tar.gz (16.9MB)
 100% |????????????????????????????????| 16.9MB 10.4MB/s 
Collecting hrpc>=1.0.5 (from pocoui)
 Downloading http://pypi.doubanio.com/packages/9a/15/8d518fc4d930d6a3e080663c1fe825ac9d63cf8ae1988ceab45c83cdf1ef/hrpc-1.0.8.tar.gz
Collecting requests (from pocoui)
 Downloading http://pypi.doubanio.com/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl (57kB)
 100% |????????????????????????????????| 61kB 18.2MB/s 
Collecting six (from pocoui)
 Downloading http://pypi.doubanio.com/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Collecting websocket-client (from pocoui)
 Downloading http://pypi.doubanio.com/packages/29/19/44753eab1fdb50770ac69605527e8859468f3c0fd7dc5a76dd9c4dbd7906/websocket_client-0.56.0-py2.py3-none-any.whl (200kB)
 100% |????????????????????????????????| 204kB 12.1MB/s 
Collecting Jinja2>=2.8 (from airtest->pocoui)
 Downloading http://pypi.doubanio.com/packages/1d/e7/fd8b501e7a6dfe492a433deb7b9d833d39ca74916fa8bc63dd1a4947a671/Jinja2-2.10.1-py2.py3-none-any.whl (124kB)
 100% |????????????????????????????????| 133kB 12.0MB/s 
Collecting Pillow>=3.4.0 (from airtest->pocoui)
 Downloading http://pypi.doubanio.com/packages/14/41/db6dec65ddbc176a59b89485e8cc136a433ed9c6397b6bfe2cd38412051e/Pillow-6.1.0-cp36-cp36m-manylinux1_x86_64.whl (2.1MB)
 100% |????????????????????????????????| 2.1MB 11.0MB/s 
Collecting facebook-wda (from airtest->pocoui)
 Downloading http://pypi.doubanio.com/packages/7a/12/dde509bd5cca43c40b1a084b56980c1803d5cb46f4bf20bb0f2675350cfe/facebook_wda-0.3.4-py3-none-any.whl
Collecting mss (from airtest->pocoui)
 Downloading http://pypi.doubanio.com/packages/67/2a/8e26437bcc840e19ca5290897d47f5405e302af27d4a6401e0b0edc39942/mss-4.0.3-py2.py3-none-any.whl
Collecting opencv-contrib-python<=3.4.2.17 (from airtest->pocoui)
 Downloading http://pypi.doubanio.com/packages/61/29/fc60b2de1713aa92946992544329f20ccb5e4ba26290f403e04b7da44105/opencv_contrib_python-3.4.2.17-cp36-cp36m-manylinux1_x86_64.whl (30.6MB)
 100% |????????????????????????????????| 30.6MB 173kB/s 
Collecting pywinauto==0.6.3 (from airtest->pocoui)
 Downloading http://pypi.doubanio.com/packages/9c/08/4b04e2e1a7b1ee8ed03e79ac1acf2948d40de8f37bff3fa7d170420fa975/pywinauto-0.6.3.zip (515kB)
 100% |????????????????????????????????| 522kB 1.8MB/s 
Collecting certifi>=2017.4.17 (from requests->pocoui)
 Downloading http://pypi.doubanio.com/packages/69/1b/b853c7a9d4f6a6d00749e94eb6f3a041e342a885b87340b79c1ef73e3a78/certifi-2019.6.16-py2.py3-none-any.whl (157kB)
 100% |????????????????????????????????| 163kB 12.7MB/s 
Collecting idna<2.9,>=2.5 (from requests->pocoui)
 Downloading http://pypi.doubanio.com/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl (58kB)
 100% |????????????????????????????????| 61kB 17.5MB/s 
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests->pocoui)
 Downloading http://pypi.doubanio.com/packages/e6/60/247f23a7121ae632d62811ba7f273d0e58972d75e58a94d329d51550a47d/urllib3-1.25.3-py2.py3-none-any.whl (150kB)
 100% |????????????????????????????????| 153kB 12.1MB/s 
Collecting chardet<3.1.0,>=3.0.2 (from requests->pocoui)
 Downloading http://pypi.doubanio.com/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
 100% |????????????????????????????????| 143kB 12.7MB/s 
Collecting MarkupSafe>=0.23 (from Jinja2>=2.8->airtest->pocoui)
 Downloading http://pypi.doubanio.com/packages/b2/5f/23e0023be6bb885d00ffbefad2942bc51a620328ee910f64abe5a8d18dd1/MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl
Collecting retry (from facebook-wda->airtest->pocoui)
 Downloading http://pypi.doubanio.com/packages/4b/0d/53aea75710af4528a25ed6837d71d117602b01946b307a3912cb3cfcbcba/retry-0.9.2-py2.py3-none-any.whl
Collecting numpy>=1.11.3 (from opencv-contrib-python<=3.4.2.17->airtest->pocoui)
 Downloading http://pypi.doubanio.com/packages/19/b9/bda9781f0a74b90ebd2e046fde1196182900bd4a8e1ea503d3ffebc50e7c/numpy-1.17.0-cp36-cp36m-manylinux1_x86_64.whl (20.4MB)
 100% |????????????????????????????????| 20.4MB 12.6MB/s 
Collecting python-xlib (from pywinauto==0.6.3->airtest->pocoui)
 Downloading http://pypi.doubanio.com/packages/f7/91/9f794491d1a8b810a9d4bb8fc9766a98354cb62bd6990685032b00f87001/python_xlib-0.25-py2.py3-none-any.whl (165kB)
 100% |????????????????????????????????| 174kB 2.4MB/s 
Collecting decorator>=3.4.2 (from retry->facebook-wda->airtest->pocoui)
 Downloading http://pypi.doubanio.com/packages/5f/88/0075e461560a1e750a0dcbf77f1d9de775028c37a19a346a6c565a257399/decorator-4.4.0-py2.py3-none-any.whl
Collecting py<2.0.0,>=1.4.26 (from retry->facebook-wda->airtest->pocoui)
 Downloading http://pypi.doubanio.com/packages/76/bc/394ad449851729244a97857ee14d7cba61ddb268dce3db538ba2f2ba1f0f/py-1.8.0-py2.py3-none-any.whl (83kB)
 100% |????????????????????????????????| 92kB 16.9MB/s 
Building wheels for collected packages: pocoui, airtest, hrpc, pywinauto
 Running setup.py bdist_wheel for pocoui ... done
 Stored in directory: /home/adog/.cache/pip/wheels/ea/20/dc/bbcabf53feb44ad7512a65ca26a93881f6dfcb26649a8c89fe
 Running setup.py bdist_wheel for airtest ... done
 Stored in directory: /home/adog/.cache/pip/wheels/2b/ce/30/7681374d47c352af5cff82dd99836dfa24eb7fabc28a0fb8c8
 Running setup.py bdist_wheel for hrpc ... done
 Stored in directory: /home/adog/.cache/pip/wheels/8d/ed/4f/1b65f18415284353e94c25484c8b5d21e6b0891da11c104666
 Running setup.py bdist_wheel for pywinauto ... done
 Stored in directory: /home/adog/.cache/pip/wheels/6b/dd/3e/6cb88548ba8d2a2cd9100758b761607601707b465362f34e84
Successfully built pocoui airtest hrpc pywinauto
Installing collected packages: MarkupSafe, Jinja2, Pillow, certifi, idna, urllib3, chardet, requests, decorator, py, retry, six, facebook-wda, mss, numpy, opencv-contrib-python, python-xlib, pywinauto, airtest, hrpc, websocket-client, pocoui
Successfully installed Jinja2-2.10.1 MarkupSafe-1.1.1 Pillow-6.1.0 airtest-1.0.27 certifi-2019.6.16 chardet-3.0.4 decorator-4.4.0 facebook-wda-0.3.4 hrpc-1.0.8 idna-2.8 mss-4.0.3 numpy-1.17.0 opencv-contrib-python-3.4.2.17 pocoui-1.0.76 py-1.8.0 python-xlib-0.25 pywinauto-0.6.3 requests-2.22.0 retry-0.9.2 six-1.12.0 urllib3-1.25.3 websocket-client-0.56.0

以上这篇python+adb命令实现自动刷视频脚本案例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持三水点靠木。

Python 相关文章推荐
使用python统计文件行数示例分享
Feb 21 Python
Python的Bottle框架中获取制定cookie的教程
Apr 24 Python
Python守护进程用法实例分析
Jun 04 Python
python中urllib.unquote乱码的原因与解决方法
Apr 24 Python
python requests post多层字典的方法
Dec 27 Python
详解pandas.DataFrame中删除包涵特定字符串所在的行
Apr 04 Python
用pycharm开发django项目示例代码
Jun 13 Python
PyTorch中的C++扩展实现
Apr 02 Python
python代码实现将列表中重复元素之间的内容全部滤除
May 22 Python
Django框架实现在线考试系统的示例代码
Nov 30 Python
matplotlib运行时配置(Runtime Configuration,rc)参数rcParams解析
Jan 05 Python
Python编解码问题及文本文件处理方法详解
Jun 20 Python
python+adb+monkey实现Rom稳定性测试详解
Apr 23 #Python
通过python调用adb命令对App进行性能测试方式
Apr 23 #Python
python 将视频 通过视频帧转换成时间实例
Apr 23 #Python
Windows下Anaconda和PyCharm的安装与使用详解
Apr 23 #Python
如何实现在jupyter notebook中播放视频(不停地展示图片)
Apr 23 #Python
Django调用百度AI接口实现人脸注册登录代码实例
Apr 23 #Python
Anaconda和ipython环境适配的实现
Apr 22 #Python
You might like
用PHP查询搜索引擎排名位置的代码
2010/01/05 PHP
一个图片地址分解程序(用于PHP小偷程序)
2014/08/23 PHP
php实现的网络相册图片防盗链完美破解方法
2015/07/01 PHP
详解PHP中array_rand函数的使用方法
2016/09/11 PHP
php 开发中加密的几种方法总结
2017/03/22 PHP
浅谈PHP各环境下的伪静态配置
2019/03/13 PHP
javascript getElementsByClassName 和js取地址栏参数
2010/01/02 Javascript
javascript获取URL参数与参数值的示例代码
2013/12/20 Javascript
javascript实现动态侧边栏代码
2014/02/19 Javascript
JavaScript 学习笔记之操作符
2015/01/14 Javascript
nodejs实现获取当前url地址及url各种参数值
2015/06/25 NodeJs
深入理解vue Render函数
2017/07/19 Javascript
nodejs微信扫码支付功能实现
2018/02/17 NodeJs
基于jQuery.i18n实现web前端的国际化
2018/05/04 jQuery
vue-cli 2.*中导入公共less文件的方法步骤
2018/11/22 Javascript
微信小程序 setData 对 data数据影响问题
2019/04/18 Javascript
微信小程序 自定义复选框实现代码实例
2019/09/04 Javascript
Python写的Tkinter程序屏幕居中方法
2015/03/10 Python
python套接字流重定向实例汇总
2016/03/03 Python
python实现用户登录系统
2016/05/21 Python
Python面向对象程序设计之继承与多继承用法分析
2018/07/13 Python
Flask框架Flask-Login用法分析
2018/07/23 Python
Python编写合并字典并实现敏感目录的小脚本
2019/02/26 Python
Python3.0 实现决策树算法的流程
2019/08/08 Python
调试Django时打印SQL语句的日志代码实例
2019/09/12 Python
python实现俄罗斯方块小游戏
2020/04/24 Python
pycharm配置安装autopep8自动规范代码的实现
2021/03/02 Python
十佳班主任事迹材料
2014/01/18 职场文书
计算机学生求职信范文
2014/01/30 职场文书
学校师德承诺书
2014/05/23 职场文书
师德先进个人材料
2014/12/20 职场文书
求职自我评价怎么写
2015/03/09 职场文书
银行保安拾金不昧表扬稿
2015/05/05 职场文书
离婚案件答辩状
2015/05/22 职场文书
Python基础之函数嵌套知识总结
2021/05/23 Python
React-vscode使用jsx语法的问题及解决方法
2021/06/21 Javascript