DDR爱好者之家 Design By 杰米

创建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写一个自动浏览文章的脚本实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

DDR爱好者之家 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
DDR爱好者之家 Design By 杰米