Python实现定时自动化收取蚂蚁森林能量,不用担心忘记收取

Python+uiautomator2定时偷取蚂蚁森林好友能量 该代码通过 uiautomator2 识别控件加图片识别方式,实现了定时收取自己的能量和偷取别人的蚂蚁森林绿色能量。 阅读详情

1. 概述

提到蚂蚁森林,大家应该都知道,你是否有因忘记收取能量而被好友收取的经历呢?

如果你不是蚂蚁森林重度用户,被别人收取了能量可能对你来说没什么。

PS:如有需要Python学习资料的小伙伴可以加点击下方链接自行获取

python免费学习资料以及群交流解答点击即可加入

但如果你是蚂蚁森林重度用户,遇到能量被偷 ...

本文我们来看一下如何使用 Python + Appium 实现定时自动化收取蚂蚁森林能量。

2. 环境

本文主要环境如下:

  • Win7
  • 小米5s
  • Python3.7
  • Appium1.5
  • 支付宝10.2.6.7010

如果对环境搭建不熟悉的话,可以看一下: Python + Appium 自动化操作微信入门 和 我用 Python 找出了删除我微信的所有人并将他们自动化删除了 。

3. 实现

功能实现的基本思路为:

  • 打开支付宝进入蚂蚁森林,收取自己的能量
  • 收取完自己能量后,点击 找能量 进入好友蚂蚁森林,收取好友能量,以此类推

接下来我们看一下主要代码实现。

参数配置代码实现如下:

desired_caps = {
    "platformName": "Android", # 系统
    "platformVersion": "8.0.0", # 系统版本号
    "deviceName": "m5s", # 设备名
    "appPackage": "com.eg.android.AlipayGphone", # 包名
    "appActivity": "AlipayLogin", # app 启动时主 Activity
    'noReset': True # 保留 session 信息,可以避免重新登录
}

通常大家都会将蚂蚁森林放在支付宝首页,此时我们打开支付宝后直接点击蚂蚁森林选项即可进入。

代码实现如下:

driver.find_elements_by_id('com.alipay.android.phone.openplatform:id/home_app_view')[10].click()

进入自己蚂蚁森林之后,开始收取自己的能量,因为新版支付宝不能定位能量球元素了,所以我们需要在能量球可能出现的区域实现点击。收取能量的代码实现如下:

# 收取能量
def collect_energy(driver):
    print('开始收取能量')
    # 获取手机屏幕宽高
    width = int(driver.get_window_size()['width'])
    height = int(driver.get_window_size()['height'])
    # 能量球可能出现的区域坐标
    start_x = 110
    end_x = 940
    start_y = 460
    end_y = 880
    for i in range(start_y, end_y, 80):
        for j in range(start_x, end_x, 80):
            tap_x1 = int((int(j) / width) * width)
            tap_y1 = int((int(i) / height) * height)
            # 点击指定坐标
            driver.tap([(tap_x1, tap_y1), (tap_x1, tap_y1)], 1000)
    print('能量收取完毕')

自己能量收取完毕之后,点击 找能量 进入好友蚂蚁森林继续收取能量,代码实现如下:

# 找能量
def search_energy(driver):
    print('找能量,收取好友能量')
    time.sleep(3)
    # 点击找能量
    driver.tap([(1000, 1520), (1080, 1580)], 1000)
    time.sleep(3)
    # 收取好友能量
    collect_energy(driver)
    time.sleep(3)
    # 收取完毕继续找能量
    search_energy(driver)

能量收取的功能实现了之后,我们使用定时任务实现定时收取即可,下面看一下定时任务的实现。

定时任务的实现我们使用 apscheduler 组件,使用之前需执行 pip install apscheduler 装一下。

定时任务的代码实现如下:

scheduler = BlockingScheduler()
# collect_main:定时执行的方法
scheduler.add_job(collect_main, 'cron', hour=20, minute=23, second=20)
try:
    scheduler.start()
except (KeyboardInterrupt, SystemExit):
    pass

到此,我们利用 Python + Appium 实现定时自动化收取蚂蚁森林能量的工作就完成了。

 

蚂蚁森林自动收取能量的脚本 利用auto.js实现的蚂蚁森林收能量脚本。 立即下载

相关推荐

支付宝蚂蚁森林能量自动收取插件开发原理解析

来自尼古拉斯_赵四2018年9月10日一篇帖子 截图为证,保留为先 来自尼古拉斯_赵四2018年9月10日一篇帖子 截图为证,保留为先 来自尼古拉斯_赵四2018年9月10日一篇帖子 截图为证,保留为先

用Python实现定时自动化收取蚂蚁森林能量,再也不用担心忘记收取了

提到蚂蚁森林,大家应该都知道,你是否有因忘记收取能量而被好友收取的经历呢?如果你不是蚂蚁森林重度用户,被别人收取了能量可能对你来说没什么。但如果你是蚂蚁森林重度用户,遇到能量被偷 …本文我们来看一下如何使用 Python + Appium 实现定时自动化收取蚂蚁森林能量。

2401_84562377的博客 1122

怀旧党必备!用iPhone4s重温iOS6的保姆级教程(含游戏资源包)

本文提供了一份详细的iPhone4s降级至iOS6.1.3的保姆级教程,包括设备准备、越狱操作、系统降级及资源优化全流程。通过自制固件和越狱工具,用户可以重温经典的拟物化设计和流畅体验,同时获取经典游戏资源包,打造复古游戏神器。

nft7creator的博客 876

最新支付宝蚂蚁森林自动偷能量,解放双手

支付宝好友300+每天偷能量要费10分钟,为解决此方法,我安装脚本,实现一键自动偷取能量。2.点auto程序,设置,看一下脚本存放的路径,然后将2中的脚本文件夹解压到该目录。具有 ROOT 权限的安卓 5.0 及以上版本。没有 ROOT 权限的安卓 7.0 及以上版本。会自动拉起支付宝的蚂蚁森林,然后进行偷取能量,1.将第一个下载好安装好,该给的权限都给了。我的设备是红米k30s 至尊纪念版。蚂蚁森林自动收能量设备要求。2022年9月7日发文。1.auto.js下载。上面2个准备好了之后。

石宗昊的博客 9231

6.2 磁悬浮轴承:软件架构与实现

本文系统阐述了磁悬浮轴承控制系统的软件架构与实现方法。采用分层架构设计,包括硬件抽象层、实时控制内核、控制算法层和应用层,确保系统实时性和可靠性。重点分析了电流环、位置环等关键控制任务的调度策略,比较了不同硬件平台(DSP、ARM、FPGA)的软件实现方案。强调模块化设计、配置化管理等工程实践,并详细介绍了从算法仿真到系统联调的完整开发流程。最后指出严格的测试验证是保证系统性能的关键,需通过多阶段测试评估起浮时间、稳态精度等核心指标。

技术工作者 752

Vivado IP核与License许可全解析:从免费到收费,从评估到部署

本文全面解析Vivado IP核与License许可机制,从免费到收费IP核的选型指南到License的申请与部署策略。详细介绍了Xilinx官方IP核的优势与局限,第三方IP核的风险与应对,以及实战中的资源优化技巧和版本兼容性问题,帮助开发者高效利用Vivado工具链。

weixin_29169505的博客 367

用 Python 实现 定时自动化收取蚂蚁森林能量,再也不用担心忘记收取能量了

1. 概述 提到蚂蚁森林,大家应该都知道,你是否有因忘记收取能量而被好友收取的经历呢? 相关文件 小伙伴们可以关注小编的Python源码、问题解答&学习交流群:733089476 有很多的资源可以白嫖的哈,需要源码的小伙伴可以在+君羊领取 如果你不是蚂蚁森林重度用户,被别人收取了能量可能对你来说没什么。 但如果你是蚂蚁森林重度用户,遇到能量被偷 … 本文我们来看一下如何使用 Python + Appium 实现定时自动化收取蚂蚁森林能量。 2. 环境 本文主要环境如下: 1.Win7 2.小米

qq_1428994977的博客 1900

【Qt】Qt6系列教程汇总_qt6教程

简介:QT相关电子书、建议和相关参考网址。

2401_87556657的博客 1183

用Python实现定时自动化收取蚂蚁森林能量,再也不用担心忘记被人偷了

本文的文字及图片来源于网络,仅供学习、交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理 以下文章来源于腾讯云 作者:Python编程与实战 ( 想要学习Python?Python学习交流群:1039649593,满足你的需求,资料都已经上传群文件流,可以自行下载!还有海量最新2020python学习资料。 ) 1. 概述 提到蚂蚁森林,大家应该都知道,你是否有因忘记收取能量而被好友收取的经历呢? 如果你不是蚂蚁森林重度用户,被别人收取了能量可能对你来说没什么。 但如果你是蚂

weixin_49345590的博客 679

大语言模型无代码构建知识图谱概述

由示例可以看出,大语言模型的泛化能力能够非常精准的抽取文本中的实体、关系等知识信息。其能够大大提升知识提取的效率与准确性。HuggingFists低代码平台的出现进一步促进了知识图谱构建的效率。它大幅降低了知识图谱构建人员的技术要求,使得从事该工作的人员有了更大的选择范围。不断下降的构建成本,意味着可以有更多的客户享受到知识图谱带来的业务价值。

colorknight的专栏 1817

数学分析五领域全景:实分析、复分析、泛函分析、傅里叶分析、凸分析

五种分析,五种视角,同一个目标。理解一个系统,首先要找到它的不变量。

li880862的博客 191

python模拟蚂蚁森林能量产生过程代码_用Python实现定时自动化收取蚂蚁森林能量,再也不用担心忘记收取了...

1. 概述提到蚂蚁森林,大家应该都知道,你是否有因忘记收取能量而被好友收取的经历呢? 如果你不是蚂蚁森林重度用户,被别人收取了能量可能对你来说没什么。 但如果你是蚂蚁森林重度用户,遇到能量被偷 ... 本文我们来看一下如何使用 Python + Appium 实现定时自动化收取蚂蚁森林能量。2. 环境本文主要环境如下:Win7小米5sPython3.7Appium1.5支付宝10.2.6.7010...

weixin_39944074的博客 734

48-OpenCVSharp —-Cv2.MatchTemplate() 函数功能(模板匹配)详解

是 OpenCV 中一个常见且简单的模板匹配算法,适用于目标检测和图像识别中的静态场景。它的优点是易于理解和实现,但在面对旋转、尺度变化、复杂背景或光照变化等挑战时,效果可能大打折扣。在这些情况下,结合多尺度图像、特征匹配算法(如 SIFT、SURF、ORB 等)以及深度学习模型可以显著提高匹配的鲁棒性和精度。模板匹配仍然是一个非常基础但强大的工具,适用于一些简单的图像匹配任务。对于更加复杂和动态的图像识别任务,我们通常会使用其他更加复杂的算法或者深度学习模型来处理。

weixin_45590420的博客 4523

苹果 python蚂蚁森林自动收能量_用Python实现定时自动化收取蚂蚁森林能量,再也不用担心忘记收取了...

2. 环境本文主要环境如下:Win7小米5sPython3.7Appium1.5支付宝10.2.6.70103. 实现功能实现的基本思路为:打开支付宝进入蚂蚁森林,收取自己的能量收取完自己能量后,点击找能量进入好友蚂蚁森林,收取好友能量,以此类推接下来我们看一下主要代码实现。参数配置代码实现如下:desired_caps = {"platformName": "Android", # 系统"pla...

weixin_39637256的博客 370

ofd转pdf报错:org.ofdrw.reader.ZipUtil.unZipFileByApacheCommonCompress【已解决】

ofd转pdf报错:java.lang.NoClassDefFoundError:org/apache/commons/io/function/IOIterator at org.ofdrw.reader.ZipUtil.unZipFileByApacheCommonCompress,java.lang.NoSuchMethodError:org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextEntry()

黄团团的个人博客 1283

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

python小二_用Python实现定时自动化收取蚂蚁森林能量,再也不用担心忘记收取了...

1. 概述提到蚂蚁森林,大家应该都知道,你是否有因忘记收取能量而被好友收取的经历呢?如果你不是蚂蚁森林重度用户,被别人收取了能量可能对你来说没什么。但如果你是蚂蚁森林重度用户,遇到能量被偷 ...本文我们来看一下如何使用 Python + Appium 实现定时自动化收取蚂蚁森林能量。2. 环境本文主要环境如下:Win7小米5sPython3.7Appium1.5支付宝10.2.6.70103. ...

weixin_31845113的博客 190

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

python支付宝蚂蚁森林_用Python实现定时自动化收取蚂蚁森林能量,再也不用担心忘记收取了...

2. 环境本文主要环境如下:Win7小米5sPython3.7Appium1.5支付宝10.2.6.70103. 实现功能实现的基本思路为:打开支付宝进入蚂蚁森林,收取自己的能量收取完自己能量后,点击找能量进入好友蚂蚁森林,收取好友能量,以此类推接下来我们看一下主要代码实现。参数配置代码实现如下:desired_caps={"platformName":"Android",#系统"pla...

weixin_39657125的博客 192

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

collect的功能是什么?其底层如何实现的?_用Python实现定时自动化收取蚂蚁森林能量,再也不用担心忘记收取了

1. 概述提到蚂蚁森林,大家应该都知道,你是否有因忘记收取能量而被好友收取的经历呢?如果你不是蚂蚁森林重度用户,被别人收取了能量可能对你来说没什么。但如果你是蚂蚁森林重度用户,遇到能量被偷 ...本文我们来看一下如何使用 Python + Appium 实现定时自动化收取蚂蚁森林能量。2. 环境本文主要环境如下:Win7小米5sPython3.7Appium1.5支付宝10.2.6.7010如果对...

weixin_39585761的博客 128
上一篇: Python爬取B站耗子尾汁、不讲武德出处的视频弹幕!
下一篇: 教你用Python制作一款带有界面的NBA爬虫小程序!
pythonlaodi
博客等级 码龄6年 286粉丝 244原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值