python修改微信和支付寶步數(shù)的示例代碼
項(xiàng)目意義
如果你想在支付寶螞蟻森林收集很多能量種樹,為環(huán)境綠化出一份力量,又或者是想每天稱霸微信運(yùn)動(dòng)排行榜裝逼,卻不想出門走路,那么該python腳本可以幫你實(shí)現(xiàn)。
實(shí)現(xiàn)方法
手機(jī)安裝第三方軟件樂心健康,注冊賬號登錄,將運(yùn)動(dòng)數(shù)據(jù)同步到微信和支付寶。用python腳本遠(yuǎn)程修改樂心健康當(dāng)前登錄賬號的步數(shù)即可。
第一步:在手機(jī)上安裝樂心健康app。

安卓版下載地址:樂心健康安卓版
蘋果版下載地址:樂心健康iOS版
樂心運(yùn)動(dòng)app for android v3.0 安卓版
第二步:注冊賬號登錄,并設(shè)置登錄密碼。

第三步:完成第三方同步,將運(yùn)動(dòng)數(shù)據(jù)同步到微信和支付寶。

第四步:運(yùn)行python腳本,修改樂心健康步數(shù)。



python代碼
程序設(shè)定是每天7點(diǎn)自動(dòng)修改步數(shù),在下面腳本對應(yīng)的位置替換填入樂心健康賬號、樂心健康密碼、修改步數(shù),然后運(yùn)行程序。修改步數(shù)推薦設(shè)置范圍是30000至90000,步數(shù)值太大會(huì)導(dǎo)致修改不成功。如果想改變第二天自動(dòng)修改步數(shù)的時(shí)間,請修改圖示位置的25200,+25200代表第二天0點(diǎn)后加上的秒數(shù),也就是7x60x60,即7小時(shí),根據(jù)自己的需要修改即可。如果每天都要修改步數(shù),那么讓程序一直保持運(yùn)行即可。
注意:運(yùn)行程序會(huì)立刻修改當(dāng)天的步數(shù),自動(dòng)修改步數(shù)是從程序保持運(yùn)行的第二天開始。


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('登錄狀態(tài)碼:%s' % status_code)
# print('登錄返回?cái)?shù)據(jù):%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 '登錄失敗'
# 修改步數(shù)
def change_step(self):
# 登錄結(jié)果
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('修改步數(shù)狀態(tài)碼:%s' % status_code)
# print('修改步數(shù)返回?cái)?shù)據(jù):%s' % response_text)
if status_code == 200:
return '修改步數(shù)為【%s】成功' % self.step
else:
return '修改步數(shù)失敗'
# 睡眠到第二天執(zhí)行修改步數(shù)的時(shí)間
def get_sleep_time():
# 第二天日期
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
# 第二天7點(diǎn)時(shí)間戳
tomorrow_run_time = int(time.mktime(time.strptime(str(tomorrow), '%Y-%m-%d'))) + 25200
# print(tomorrow_run_time)
# 當(dāng)前時(shí)間戳
current_time = int(time.time())
# print(current_time)
return tomorrow_run_time - current_time
if __name__ == "__main__":
# 最大運(yùn)行出錯(cuò)次數(shù)
fail_num = 3
while 1:
while fail_num > 0:
try:
# 修改步數(shù)結(jié)果
result = LexinSport('樂心健康賬號', '樂心健康密碼', 修改步數(shù)).change_step()
print(result)
break
except Exception as e:
print('運(yùn)行出錯(cuò),原因:%s' % e)
fail_num -= 1
if fail_num == 0:
print('修改步數(shù)失敗')
# 重置運(yùn)行出錯(cuò)次數(shù)
fail_num = 3
# 獲取睡眠時(shí)間
sleep_time = get_sleep_time()
time.sleep(sleep_time)
修改樂心健康步數(shù)項(xiàng)目下載地址:
鏈接: https://pan.baidu.com/s/1vW_4tG4yIR0YJQkdkgjc6A
提取碼: fn56
到此這篇關(guān)于python修改微信和支付寶步數(shù)的示例代碼的文章就介紹到這了,更多相關(guān)python修改微信和支付寶步數(shù)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- 基于Python采集爬取微信公眾號歷史數(shù)據(jù)
- python制作定時(shí)發(fā)送信息腳本的實(shí)現(xiàn)思路
- Python爬取微信小程序通用方法代碼實(shí)例詳解
- python向企業(yè)微信發(fā)送文字和圖片消息的示例
- Python 實(shí)現(xiàn)微信自動(dòng)回復(fù)的方法
- Python selenium爬取微信公眾號文章代碼詳解
- Python爬蟲爬取微信朋友圈
- python操作微信自動(dòng)發(fā)消息的實(shí)現(xiàn)(微信聊天機(jī)器人)
- Python Flask微信小程序登錄流程及登錄api實(shí)現(xiàn)代碼
- Python使用20行代碼實(shí)現(xiàn)微信聊天機(jī)器人
- Python實(shí)現(xiàn)清理微信僵尸粉功能示例【基于itchat模塊】
- 用 python 進(jìn)行微信好友信息分析
相關(guān)文章
PySide(PyQt)使用QPropertyAnimation制作動(dòng)態(tài)界面的示例代碼
文章介紹了如何使用PySide或PyQt的QPropertyAnimation類來創(chuàng)建動(dòng)態(tài)界面效果,感興趣的朋友一起看看吧2025-03-03
Python實(shí)現(xiàn)將內(nèi)容轉(zhuǎn)為base64編碼與解碼
這篇文章主要為大家詳細(xì)介紹了Python實(shí)現(xiàn)將內(nèi)容轉(zhuǎn)為base64編碼與解碼的示例代碼,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解一下2023-02-02
Python使用type關(guān)鍵字創(chuàng)建類步驟詳解
在本文里我們給讀者們整理了關(guān)于Python如何使用type關(guān)鍵字創(chuàng)建類的相關(guān)知識(shí)點(diǎn),需要的朋友們參考學(xué)習(xí)下。2019-07-07
Python使用APScheduler實(shí)現(xiàn)定時(shí)任務(wù)過程解析
這篇文章主要介紹了Python使用APScheduler實(shí)現(xiàn)定時(shí)任務(wù)過程解析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-09-09
Python3如何日志同時(shí)輸出到控制臺(tái)和文件
這篇文章主要介紹了Python3如何日志同時(shí)輸出到控制臺(tái)和文件問題,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-11-11
python使用collections模塊的容器數(shù)據(jù)類型高效處理數(shù)據(jù)
這篇文章主要為大家介紹了python使用collections模塊的容器數(shù)據(jù)類型高效處理數(shù)據(jù)的方法示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-06-06
Python 用turtle實(shí)現(xiàn)用正方形畫圓的例子
今天小編就為大家分享一篇Python 用turtle實(shí)現(xiàn)用正方形畫圓的例子,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-11-11

