1. 程式人生 > 實用技巧 >資本寵兒極鏈科技頻踩雷:阿里、曠視科技是股東,AI成擺設?

資本寵兒極鏈科技頻踩雷:阿里、曠視科技是股東,AI成擺設?

今天分享的文章讓你霸屏微信運動,橫掃支付寶榜單

1.專案意義

如果你想在支付寶螞蟻森林收集很多能量種樹,為環境綠化出一份力量,又或者是想每天稱霸微信運動排行榜裝逼,卻不想出門走路,那麼該 python 指令碼可以幫你實現。

2.實現方法

手機安裝第三方軟體樂心健康,註冊賬號登入,將運動資料同步到微信和支付寶。用 python 指令碼遠端修改樂心健康當前登入賬號的步數即可。

第一步:在手機上安裝樂心健康 app。​安卓版下載地址:(http://app.mi.com/details?id=gz.lifesense.weidong)

蘋果版下載地址:(https://apps.apple.com/us/app/lifesense-health/id1479525632)

第二步:註冊賬號登入,並設定登入密碼。

第三步:完成第三方同步,將運動資料同步到微信和支付寶。

第四步:執行 python 指令碼,修改樂心健康步數。



3.python 程式碼

程式設定是每天 7 點自動修改步數,在下面指令碼對應的位置替換填入樂心健康賬號、樂心健康密碼、修改步數,然後執行程式。修改步數推薦設定範圍是 30000 至 90000,步數值太大會導致修改不成功。如果想改變第二天自動修改步數的時間,請修改圖示位置的 25200,+25200 代表第二天 0 點後加上的秒數,也就是 7x60x60,即 7 小時,根據自己的需要修改即可。如果每天都要修改步數,那麼讓程式一直保持執行即可。

注意:執行程式會立刻修改當天的步數,自動修改步數是從程式保持執行的第二天開始。


部分原始碼,全部原始碼獲取方式見文末

#-*-coding:utf-8-*-
importrequests
importjson
importhashlib
importtime
importdatetime


classLexinSport:
def__init__(self,username,password,step):
self.username=username
self.password=password
self.step=step

#登入
deflogin(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;Android7.1.2;LIO-AN00Build/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)
ifstatus_code==200:
response_text=json.loads(response_text)
user_id=response_text['data']['userId']
access_token=response_text['data']['accessToken']
returnuser_id,access_token
else:
return'登入失敗'

#修改步數
defchange_step(self):
#登入結果
login_result=self.login()
iflogin_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)
ifstatus_code==200:
return'修改步數為【%s】成功'%self.step
else:
return'修改步數失敗'


#睡眠到第二天執行修改步數的時間
defget_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)
returntomorrow_run_time-current_time


if__name__=="__main__":
#最大執行出錯次數
fail_num=3
while1:
whilefail_num>0:
try:
#修改步數結果
result=LexinSport('樂心健康賬號','樂心健康密碼',修改步數).change_step()
print(result)
break
exceptExceptionase:
print('執行出錯,原因:%s'%e)
fail_num-=1
iffail_num==0:
print('修改步數失敗')
#重置執行出錯次數
fail_num=3
#獲取睡眠時間
sleep_time=get_sleep_time()
time.sleep(sleep_time)

  

原始碼及相關檔案在公眾號後臺回覆愛運動獲取

最通俗的解讀,最深刻的乾貨,最簡潔的教程,眾多你不知道的小技巧等你來發現!

歡迎關注公眾號:「智閱薈」,懂技術,更懂你!

↑關注上方公眾號回覆愛運動即可下載↑

說明:本站提供的所有軟體已經過360、火絨安全檢測,在使用中如有問題可在公眾號留言!