python爬取微信运动_用 Python 修改微信(支付宝)运动步数,轻松 TOP1
點擊上方藍(lán)字關(guān)注我們
點擊上方“
印象python
”,選擇“
星標(biāo)
”公眾號
重磅干貨,第一時間送達(dá)!
今天分享的文章讓你霸屏微信運動,橫掃支付寶榜單。
項目意義
如果你想在支付寶螞蟻森林收集很多能量種樹,為環(huán)境綠化出一份力量,又或者是想每天稱霸微信運動排行榜裝逼,卻不想出門走路,那么該 python 腳本可以幫你實現(xiàn)。
實現(xiàn)方法
手機安裝第三方軟件樂心健康,注冊賬號登錄,將運動數(shù)據(jù)同步到微信和支付寶。用 python 腳本遠(yuǎn)程修改樂心健康當(dāng)前登錄賬號的步數(shù)即可。
第一步:在手機上安裝樂心健康 app。
安卓版下載地址:(http://app.mi.com/details?id=gz.lifesense.weidong)
蘋果版下載地址:( https://apps.apple.com/us/app/lifesense-health/id1479525632 )
第二步:注冊賬號登錄,并設(shè)置登錄密碼。
第三步:完成第三方同步,將運動數(shù)據(jù)同步到微信和支付寶。
第四步:運行 python 腳本,修改樂心健康步數(shù)。
python 代碼
程序設(shè)定是每天 7 點自動修改步數(shù),在下面腳本對應(yīng)的位置替換填入樂心健康賬號、樂心健康密碼、修改步數(shù),然后運行程序。修改步數(shù)推薦設(shè)置范圍是 30000 至 90000,步數(shù)值太大會導(dǎo)致修改不成功。如果想改變第二天自動修改步數(shù)的時間,請修改圖示位置的 25200,+25200 代表第二天 0 點后加上的秒數(shù),也就是 7x60x60,即 7 小時,根據(jù)自己的需要修改即可。如果每天都要修改步數(shù),那么讓程序一直保持運行即可。
注意:運行程序會立刻修改當(dāng)天的步數(shù),自動修改步數(shù)是從程序保持運行的第二天開始。
部分源碼,全部源碼獲取方式見文末
#?-*-?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('登錄返回數(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ù)返回數(shù)據(jù):%s'?% response_text)
if?status_code?==?200:
return?'修改步數(shù)為【%s】成功'?%?self.step
else:
return?'修改步數(shù)失敗'
#?睡眠到第二天執(zhí)行修改步數(shù)的時間
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)
#?當(dāng)前時間戳
current_time?=?int(time.time())
#?print(current_time)
return?tomorrow_run_time?-?current_time
if?__name__?==?"__main__":
#?最大運行出錯次數(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('運行出錯,原因:%s'?%?e)
fail_num?-=?1
if?fail_num?==?0:
print('修改步數(shù)失敗')
#?重置運行出錯次數(shù)
fail_num?=?3
#?獲取睡眠時間
sleep_time?=?get_sleep_time()
time.sleep(sleep_time)
回復(fù)下方 「關(guān)鍵詞」,獲取優(yōu)質(zhì)資源
回復(fù)關(guān)鍵詞 「linux」,即可獲取 185 頁 Linux 工具快速教程手冊和154頁的Linux筆記。
回復(fù)關(guān)鍵詞 「Python進(jìn)階」,即可獲取 106 頁 Python 進(jìn)階文檔 PDF
回復(fù)關(guān)鍵詞 「Python面試題」,即可獲取最新?100道?面試題 PDF
回復(fù)關(guān)鍵詞 「python數(shù)據(jù)分析」,即可獲取47頁python數(shù)據(jù)分析與自然語言處理的 PDF
回復(fù)關(guān)鍵詞 「python爬蟲」,滿滿五份PPT爬蟲教程和70多個案例
回復(fù)關(guān)鍵詞 「Python最強基礎(chǔ)學(xué)習(xí)文檔」,即可獲取 168 頁 Python 最強基礎(chǔ)學(xué)習(xí)文檔 PDF,讓你快速入門Python
推薦我的微信號
來圍觀我的朋友圈,我的經(jīng)驗分享,技術(shù)更新,不定期送書,坑位有限,速速掃碼添加!
備注:開發(fā)方向_昵稱_城市,另送你10本Python電子書。
點個在看 你最好看
總結(jié)
以上是生活随笔為你收集整理的python爬取微信运动_用 Python 修改微信(支付宝)运动步数,轻松 TOP1的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【自动化测试】整理各种测试开发工具!持续
- 下一篇: 解决AttributeError: 's