adbutils结合Python自动小说翻页

import adbutils
import os
import datetime
import time

class OriginOS_Platform_Tools:
    def __init__(self,address,port='5555'):
        if port:
            tcpip='{ip}:{port}'.format(ip=address,port=port)
        else:
            tcpip=address# 非IP地址是 将port值设置为None
        self.tcpip=tcpip
        adb = adbutils.AdbClient(host="127.0.0.1", port=5037)
        self.device = adb.device(self.tcpip)
        output = adb.connect(tcpip)
        # print(output)
        self.width,self.height=self.device.window_size()
        
    def swipe_ext(self,direction,scale=0.9,loc=0.5,duration=0.5):
        # 默认0.9, 滑动距离为屏幕宽度的90% duration 默认0.5s
        width=self.width
        height=self.height
        d=self.device
        if direction=='up':
            sx,ex=width*loc,width*loc
            sy,ey=(height-(height*scale))/2+height*scale,(height-(height*scale))/2
        elif direction=='down':
            sx,ex=width*loc,width*loc
            sy,ey=(height-(height*scale))/2,(height-(height*scale))/2+height*scale
        elif direction=='right':
            sy,ey=height*loc,height*loc
            sx,ex=(width-(width*scale))/2,(width-(width*scale))/2+width*scale
        elif direction=='left':
            sy,ey=height*loc,height*loc
            sx,ex=(width-(width*scale))/2+width*scale,(width-(width*scale))/2
        d.swipe(sx, sy, ex, ey, duration)
        return (sx, sy, ex, ey)
            
    def timepiece(sefl,seconds,fps=5):
        '''
        倒计时:秒
        刷新率:1秒内更新次数
        '''
        on_time=datetime.datetime.now()+datetime.timedelta(seconds=seconds)
        while on_time > datetime.datetime.now():
            total_seconds=(on_time-datetime.datetime.now()).total_seconds()
            print('{: ^3}秒倒计时:{: ^6.2f}秒'.format(seconds,total_seconds),end='\r')
            time.sleep(1/fps)
        else:
            print('{: ^3}秒倒计时:{: ^6.2f}秒'.format(seconds,0),end='\r')
OriginOS3=OriginOS_Platform_Tools('192.168.1.2')
import random
for i in range(100000):
    OriginOS3.swipe_ext('left',0.75,0.85)# vivo浏览器小说
    OriginOS3.swipe_ext('left',0.4)# 抖音极速版悬浮窗口
    seconds=random.randint(9,10)
    OriginOS3.timepiece(seconds,fps=5)

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值