python 微信阅读自动翻页 刷时长 兑书币

微信读书自动翻页

思路:使用Python调用adb工具实现微信阅读自动翻页

1、所需工具:python3.7、adb工具包、安卓模拟器(mumu,夜神等都可);

2、前期准备:

2.1、将以上工具均进行安装或解压工作;

2.2、mumu模拟器安装微信阅读app;

3、代码

# encoding:utf-8


from subprocess import run
import time
import random
import os

def book(rv_sel, rv_page_num, rv_t1, rv_t2):
    rv_sel = int(rv_sel)
    if rv_sel == 1:
        print('程序运行中')
        for i in range(rv_page_num):
            time.sleep(random.uniform(rv_t1,rv_t2))
            run('adb shell input swipe 1000 600 200 600', shell=True)
            n = i + 1
            print('总计需翻阅 %d 页,已翻阅 %d 页,剩余 %d 页' % (rv_page_num, n, rv_page_num - n))
        exit()
    elif rv_sel == 2:
        print('程序运行中')
        for i in range(rv_page_num):
            time.sleep(random.uniform(rv_t1,rv_t2))
            run('adb shell input swipe 200 600 1000 600', shell=True)
            n = i + 1
            print('总计需翻阅 %d 页,已翻阅 %d 页,剩余 %d 页' % (rv_page_num, n, rv_page_num - n))
        exit()
    else:
        print()
        print('* ' * 8, '1.正循环-倒循环,无限循环', '* ' * 8)
        print('* ' * 8, '2.倒循环-正循环,无限循环', '* ' * 8)
        print()
        loop = int(input('请选择循环方式:'))
        print('程序运行中')
        if loop == 1:
            while 1:
                for i in range(rv_page_num):
                    time.sleep(random.uniform(rv_t1,rv_t2))
                    run('adb shell input swipe 1000 600 200 600', shell=True)
                    n = i + 1
                    print('总计需翻阅 %d 页,已翻阅 %d 页,剩余 %d 页' % (rv_page_num, n, rv_page_num - n))
                for i in range(rv_page_num):
                    time.sleep(random.uniform(rv_t1,rv_t2))
                    run('adb shell input swipe 200 600 1000 600', shell=True)
                    n = i + 1
                    print('总计需翻阅 %d 页,已翻阅 %d 页,剩余 %d 页' % (rv_page_num, n, rv_page_num - n))
        else:
            while 1:
                for i in range(rv_page_num):
                    time.sleep(random.uniform(rv_t1,rv_t2))
                    run('adb shell input swipe 200 600 1000 600', shell=True)
                    n = i + 1
                    print('总计需翻阅 %d 页,已翻阅 %d 页,剩余 %d 页' % (rv_page_num, n, rv_page_num - n))
                for i in range(rv_page_num):
                    time.sleep(random.uniform(rv_t1,rv_t2))
                    run('adb shell input swipe 1000 600 200 600', shell=True)
                    n = i + 1
                    print('总计需翻阅 %d 页,已翻阅 %d 页,剩余 %d 页' % (rv_page_num, n, rv_page_num - n))

def rand_time(rv_xh):
    if int(rv_xh) == 1:
        return 10,20
    else:
        while 1:
            t1 = int(input('请输入最小等待时间:'))
            t2 = int(input('请输入最大等待时间:'))
            if t2 >= t1:
                return t1,t2
                break
            else:
                print('最小时间不得小于最大时间,请重新输入')

print('* ' * 50,)
print('告知:')
print('信阅读暂未公布有效翻阅取时规则,如自动翻页未获得有效阅读时间,请及时增加翻阅时间间隔')
print('请选择间隔时间方式:')
print('1.系统推荐:10—20秒')
print('2.自主输入:0—+∞',)
print('* ' * 50,)
while 1:
    xh = input('请输入序号:')
    if xh == '':
        print('输入有误,请重新输入')
    elif xh in str([1,2]):
        t1,t2 = rand_time(xh)
        break
    else:
        print('输入有误,请重新输入')
run('cd e:\tool\adb', shell=True)  # 将cd 后的路径改为自己的adb解压路径
run('adb connect 127.0.0.1:7555', shell=True)   # 每个模拟器端口不一致,可Google
while 1:
    print()
    print('* ' * 8, '1.正翻', '* ' * 8)
    print('* ' * 8, '2.倒翻', '* ' * 8)
    print('* ' * 8, '3.连环', '* ' * 8)
    print()
    sel = input('请选择翻书方式:')
    if sel in str([1,2,3]):
        page_num = int(input('请输入书籍总页数:'))
        book(sel,page_num,t1,t2)
    elif sel == '':
        print('输入错误')
    else:
        print('输入错误')

注意事项:

1、run('cd e:\tool\adb', shell=True) 中的e:\tool\adb需修改为自己的cdb工具包解压路径
2、run('adb connect 127.0.0.1:7555', shell=True) ,每个模拟器端口需自己百度搜索
3、run('adb shell input swipe 200 600 1000 600', shell=True) 源码中的adb shell input swipe <起始横坐标> <起始纵坐标> <结束横坐标> <结束纵坐标> 需要修改为自己的模拟器相应坐标

你可能感兴趣的:(python 微信阅读自动翻页 刷时长 兑书币)