当前位置:首页 » python教程 » 正文

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

看: 1321次  时间:2020-07-17  分类 : python教程

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博客。

标签:requests  urllib  numpy  

<< 上一篇 下一篇 >>

搜索

推荐资源

  Powered By python教程网   鲁ICP备18013710号
python博客 - 小白学python最友好的网站!