python response_用 Python 修改微信、支付宝运动步数,轻松拿到 TOP1!

关注上方“Python数据科学”,选择星标,关键时间,第一时间送达!

☞500g+超全学习资源免费领取 

fa86b2cd4cceeccefbab7d76964a7cf4.png 作者:Tsubasa_Ou https://blog.csdn.net/jiangfan2017/article/details/108984940 今天分享的文章让你霸屏微信运动,横扫支付宝榜单。 1

   

项目意义 如果你想在支付宝蚂蚁森林收集很多能量种树,为环境绿化出一份力量,又或者是想每天称霸微信运动排行榜装逼,却不想出门走路,那么该 python 脚本可以帮你实现。 2

   

实现方法 手机安装第三方软件乐心健康,注册账号登录,将运动数据同步到微信和支付宝。用 python 脚本远程修改乐心健康当前登录账号的步数即可。 第一步:在手机上安装乐心健康 app。

0a87a3c8dc7379b9225880ca1f316515.png

安卓版下载地址:http://app.mi.com/details?id=gz.lifesense.weidong 苹果版下载地址:https://apps.apple.com/us/app/lifesense-health/id1479525632 第二步:注册账号登录,并设置登录密码。
8baad233cbf800963de4cbdcdd933166.png
第三步:完成第三方同步,将运动数据同步到微信和支付宝。
505054664afb2030d3ba5fead6383639.png
第四步:运行 python 脚本,修改乐心健康步数。

e2fe4293093e25c9f5dddf55021be06f.png

734edaa24828b75e40585bd4baf740d5.png

28dae24ac2f386074717a7b1288e6088.png

3

   

python 代码 程序设定是每天 7 点自动修改步数,在下面脚本对应的位置替换填入乐心健康账号、乐心健康密码、修改步数,然后运行程序。修改步数推荐设置范围是 30000 至 90000,步数值太大会导致修改不成功。如果想改变第二天自动修改步数的时间,请修改图示位置的 25200,+25200 代表第二天 0 点后加上的秒数,也就是 7x60x60,即 7 小时,根据自己的需要修改即可。如果每天都要修改步数, 那么让程序一直保持运行即可。 注意:运行程序会立刻修改当天的步数,自动修改步数是从程序保持运行的第二天开始。 927860a6476292c5748d3b40c6c88657.png 08a7fd558c130fd93899b94a939f41c9.png 部分源码,全部源码获取方式见文末。
# -*- 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_tokenelse: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.stepelse: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_timeif __name__ == "__main__":# 最大运行出错次数
    fail_num = 3while 1:while fail_num > 0:
            try:# 修改步数结果
                result = LexinSport('乐心健康账号', '乐心健康密码', 修改步数).change_step()print(result)break
            except Exception as e:print('运行出错,原因:%s' % e)
                fail_num -= 1if fail_num == 0:print('修改步数失败')# 重置运行出错次数
        fail_num = 3# 获取睡眠时间
        sleep_time = get_sleep_time()
        time.sleep(sleep_time)
源码及相关文件在公众号后台回复 步数 获取。

特别推荐特别推荐:一个优质的推荐Github开源项目的公众号「GitHuboy」,每天给大家分享前沿、优质的项目,涉及 Java、Python、Go、Web前端、AI、数据分析等多个领域,非常值得大家关注。

回复「Java学习」获得 1024G Java学习资料回复「Python学习」获得 100G Python学习资料8ae0752693ef7b41a67e9fc45cf82413.png
推荐阅读

吴恩达给 74 岁老父亲发证了!8 年完成 146 门课程!

刷爆全网的动态条形图,原来 5 行 Python 代码就能实现!剑桥大学:PyTorch 已 碾 压 TensorFlow我半夜爬了严选的女性文胸数据,发现了惊天秘密详解 Python 操作 PPT 的各种骚操作!牛X!用 Echarts 打造一个轮播图!新一代Notebook神器出现,Jupyter危险了!🧐分享、点赞、在看,给个三连击呗!👇
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值