python修改微信和支付宝步数的示例代码
作者:python之恋 时间:2021-08-31 08:45:06
项目意义
如果你想在支付宝蚂蚁森林收集很多能量种树,为环境绿化出一份力量,又或者是想每天称霸微信运动排行榜装逼,却不想出门走路,那么该python脚本可以帮你实现。
实现方法
手机安装第三方软件乐心健康,注册账号登录,将运动数据同步到微信和支付宝。用python脚本远程修改乐心健康当前登录账号的步数即可。
第一步:在手机上安装乐心健康app。
安卓版下载地址:乐心健康安卓版
苹果版下载地址:乐心健康iOS版
乐心运动app for android v3.0 安卓版
第二步:注册账号登录,并设置登录密码。
第三步:完成第三方同步,将运动数据同步到微信和支付宝。
第四步:运行python脚本,修改乐心健康步数。
python代码
程序设定是每天7点自动修改步数,在下面脚本对应的位置替换填入乐心健康账号、乐心健康密码、修改步数,然后运行程序。修改步数推荐设置范围是30000至90000,步数值太大会导致修改不成功。如果想改变第二天自动修改步数的时间,请修改图示位置的25200,+25200代表第二天0点后加上的秒数,也就是7x60x60,即7小时,根据自己的需要修改即可。如果每天都要修改步数,那么让程序一直保持运行即可。
注意:运行程序会立刻修改当天的步数,自动修改步数是从程序保持运行的第二天开始。
change_step.py
# -*- coding: utf-8 -*-
import requests
import json
import hashlib
import time
import datetime
class LexinSport:
def __init__(self, username, password, step):
self.username = username
self.password = password
self.step = step
# 登录
def login(self):
url = 'https://sports.lifesense.com/sessions_service/login?systemType=2&version=4.6.7'
data = {'loginName': self.username, 'password': hashlib.md5(self.password.encode('utf8')).hexdigest(),
'clientId': '49a41c9727ee49dda3b190dc907850cc', 'roleType': 0, 'appType': 6}
headers = {
'Content-Type': 'application/json; charset=utf-8',
'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 7.1.2; LIO-AN00 Build/LIO-AN00)'
}
response_result = requests.post(url, data=json.dumps(data), headers=headers)
status_code = response_result.status_code
response_text = response_result.text
# print('登录状态码:%s' % status_code)
# print('登录返回数据:%s' % response_text)
if status_code == 200:
response_text = json.loads(response_text)
user_id = response_text['data']['userId']
access_token = response_text['data']['accessToken']
return user_id, access_token
else:
return '登录失败'
# 修改步数
def change_step(self):
# 登录结果
login_result = self.login()
if login_result == '登录失败':
return '登录失败'
else:
url = 'https://sports.lifesense.com/sport_service/sport/sport/uploadMobileStepV2?systemType=2&version=4.6.7'
data = {'list': [{'DataSource': 2, 'active': 1, 'calories': int(self.step/4), 'dataSource': 2,
'deviceId': 'M_NULL', 'distance': int(self.step/3), 'exerciseTime': 0, 'isUpload': 0,
'measurementTime': time.strftime('%Y-%m-%d %H:%M:%S'), 'priority': 0, 'step': self.step,
'type': 2, 'updated': int(round(time.time() * 1000)), 'userId': login_result[0]}]}
headers = {
'Content-Type': 'application/json; charset=utf-8',
'Cookie': 'accessToken=%s' % login_result[1]
}
response_result = requests.post(url, data=json.dumps(data), headers=headers)
status_code = response_result.status_code
# response_text = response_result.text
# print('修改步数状态码:%s' % status_code)
# print('修改步数返回数据:%s' % response_text)
if status_code == 200:
return '修改步数为【%s】成功' % self.step
else:
return '修改步数失败'
# 睡眠到第二天执行修改步数的时间
def get_sleep_time():
# 第二天日期
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
# 第二天7点时间戳
tomorrow_run_time = int(time.mktime(time.strptime(str(tomorrow), '%Y-%m-%d'))) + 25200
# print(tomorrow_run_time)
# 当前时间戳
current_time = int(time.time())
# print(current_time)
return tomorrow_run_time - current_time
if __name__ == "__main__":
# 最大运行出错次数
fail_num = 3
while 1:
while fail_num > 0:
try:
# 修改步数结果
result = LexinSport('乐心健康账号', '乐心健康密码', 修改步数).change_step()
print(result)
break
except Exception as e:
print('运行出错,原因:%s' % e)
fail_num -= 1
if fail_num == 0:
print('修改步数失败')
# 重置运行出错次数
fail_num = 3
# 获取睡眠时间
sleep_time = get_sleep_time()
time.sleep(sleep_time)
修改乐心健康步数项目下载地址:
链接: https://pan.baidu.com/s/1vW_4tG4yIR0YJQkdkgjc6A
提取码: fn56
来源:https://www.cnblogs.com/pythonzhilian/archive/2020/10/12/13802361.html
标签:python,微信,支付宝,步数
0
投稿
猜你喜欢
Python切片知识解析
2022-06-07 06:31:58
免费手机号码归属地API查询接口和PHP使用实例分享
2023-10-31 08:06:37
MYSQL和ORACLE的一些操作区别
2008-12-18 14:33:00
mysql 安装使用小记
2011-02-23 12:33:00
python中Event实现线程间同步介绍
2023-08-18 07:07:08
opencv之为图像添加边界的方法示例
2022-03-25 03:37:20
javascript设计模式交流(二) Prototype Pattern
2007-11-29 14:01:00
如何用Python破解wifi密码过程详解
2021-06-03 05:32:38
PHP+JS实现文件分块上传的示例代码
2023-06-12 00:04:07
python数据库操作指南之PyMysql使用详解
2023-01-02 04:04:17
python版单链表反转
2021-08-20 17:11:12
网站注册那些事儿
2010-01-05 16:49:00
成为一个顶级设计师的第二准则
2008-04-01 09:41:00
多栏自适应布局问题浅谈
2010-08-16 12:56:00
django框架实现一次性上传多个文件功能示例【批量上传】
2022-03-30 09:00:43
使用window.name解决跨域问题
2008-09-04 12:10:00
Python数据结构之图的存储结构详解
2021-03-28 10:42:48
Python3爬虫RedisDump的安装步骤
2023-07-17 00:42:15
XML:OpenSearch 浏览器指定搜索应用
2010-05-04 19:37:00
PHP析构函数destruct与垃圾回收机制的讲解
2023-07-11 21:05:36