使用python写一个自动浏览文章的脚本实例
(编辑:jimmy 日期: 2024/11/20 浏览:3 次 )
创建python文件fling.py,代码如下:
#!/usr/bin/env monkeyrunner import time from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice device = MonkeyRunner.waitForConnection(5) loop = 0 loop_back = 0 # fling up def scrollUpFling(): device.touch(100, 500, MonkeyDevice.DOWN) device.touch(100, 100, MonkeyDevice.MOVE) device.touch(100, 100, MonkeyDevice.UP) print "fling up" # fling down def scrollDownFling(): device.touch(100, 400, MonkeyDevice.DOWN) device.touch(100, 500, MonkeyDevice.MOVE) device.touch(100, 500, MonkeyDevice.UP) print "fling down" # click def clickItem(): device.touch(600,600,'DOWN_AND_UP') print "click item" # back def back(): device.touch(60,160,'DOWN_AND_UP') print "back item" def fling(): global loop global loop_back while True: scrollUpFling() time.sleep(5) scrollDownFling() time.sleep(5) scrollUpFling() time.sleep(5) loop = loop + 1; loop_back = loop_back + 1; if (loop > 3): loop = 0; clickItem() if (loop_back > 30): loop_back = 0 back() fling()
使用cmd工具,执行monkeyrunner C:\Users\andre.ou\Desktop\fling.py
以上这篇使用python写一个自动浏览文章的脚本实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
下一篇:Python字节单位转换实例