您的位置:首页 > 编程语言 > Python开发

Python自动化完成tb喵币任务

2020-01-13 17:25 85 查看
原创

Python自动化完成tb喵币任务

置顶 2019-10-24 23:12:26 菜鸟上路_lbz 阅读数 9118 文章标签: Python 自动化 版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。 本文链接:https://blog.csdn.net/qq_44198436/article/details/102734420

2019双十一,tb推出了新的活动,商店喵币,看了一下每天都有几个任务来领取喵币,从而升级店铺赚钱,然而我既想赚红包又不想干苦力,遂使用python来进行手机自动化操作,目测全网首发!

用到的库:
re
os
time
  • 1
  • 2
  • 3
  • 4
[/code]

思路:

  1. 下载adb命令安装包
  2. 打开手机开发者选项(点击系统设置,连点5次系统版本,即可在辅助功能或其他选项中找到开发者选项,此功能无害,可不必关闭)
  3. 在开发者选项中找到USB调试打开(反是有USB字样选项的全部同意,有提示风险也同意,PS:自己操作鸡毛风险没有,在一些商厦的有免费充电桩,若此充电桩提示请求USB调试请拒绝,此行为是风险操作,有可能获取隐私!)
  4. 手机连接电脑
    5. 将仅限USB充电调至MIDI模式(部分手机有,任务栏下拉) (部分手机在仅充电模式下无法连接)
  5. 调至tb喵币做任务界面
  6. 将.py文件移动至adb文件夹目录下
  7. 在开发者界面下打开指针位置
  8. 填入X,Y坐标
  9. 运行脚本
import os,re
import time
print('-----ctrl+c终止程序-----------')
task=int(input('请输入任务个数:'))
chose=int(input('请选择自定位[1]或手动输入[2]:'))
print('author:刘秉哲')
list=[]
list1=[]
def go(x,y):
for i in range(task+1):
os.system('adb shell input tap {} {}'.format(x,y))#触摸店铺按钮
print('---开始任务---')
time.sleep(4)
os.system('adb shell input tap {} {}'.format(1,1))#模拟滑动界面
print('---等待25秒---')
time.sleep(25)
print('---领取完成---')
time.sleep(4)
os.system('adb shell input keyevent 4')
time.sleep(4)
#os.system('adb shell input tap 518 2202')
print('第{}任务领取完成'.format(i+1))
print('______________________')
def go_2():
try:
print('获取坐标中')
file = os.listdir('.')
if os.path.exists('123.txt'):
#if (i.endswith('.txt')):#判断当前文件是否有123.txt
c=open('123.txt',encoding='UTF-8')
a=c.read()
#正则寻找去进店的按钮位置
d=re.search('<node index="2" text="去进店"(.*?)/>',a).groups()
f=re.search(' bounds="(.*?)"',str(d)).groups()
g=re.search('\[(.*?)\]',f[0]).group(1)
list.append(g.split(','))#将坐标添加到列表
else:
try:#这里两次获取xml,以防获取的第一个为安卓非IDE情况下的xml
os.system('adb shell uiautomator dump /sdcard/ui.xml')
time.sleep(2)
os.system('adb shell uiautomator dump /sdcard/ui.xml')
os.system('adb pull /sdcard/ui.xml 123.txt')
size=get_FileSize('123.txt')#123.txt是淘宝喵币任务页面的布局
if size>=0.03:#第一次获取ui会出现文件非淘宝苗币的xml
file = os.listdir('.')
c=open('123.txt',encoding='UTF-8')
a=c.read()
d=re.search('<node index="2" text="去进店"(.*?)/>',a).groups()
f=re.search(' bounds="(.*?)"',str(d)).groups()
g=re.search('\[(.*?)\]',f[0]).group(1)
list.append(g.split(','))
print('获取成功')
else:
print('xml文件错误正在重新下载,请勿翻动手机界面')
os.remove('123.txt')
go_2()
except:
print('错误')
go_2()
except:
print('error,正在重新获取')
def get_FileSize(filePath):
fsize = os.path.getsize(filePath)
fsize = fsize/float(1024 * 1024)
return round(fsize, 2)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: