参考https://zhuanlan.zhihu.com/p/629476969 , 每月要更新一次refresh_token
把代码放到阿里/华为/腾讯云上定时运行函数流就行了
# -*- coding:utf-8 -*-
import datetime
import requests
import typing as t
from dateutil.relativedelta import relativedelta
def get_token(refresh_token: str) -> t.Tuple[t.Any, t.Any]:
"""获取access_token和用户名"""
resj = requests.post(
'https://auth.aliyundrive.com/v2/account/token',
json={
'grant_type': 'refresh_token',
'refresh_token': refresh_token
}
).json()
return resj.get('access_token'), resj.get('user_name')
def get_sign_in_count(access_token: str) -> str:
"""获取签到次数"""
resj = requests.post(
'https://member.aliyundrive.com/v1/activity/sign_in_list',
json={'_rx-s': 'mobile'},
headers={
'Authorization': f'Bearer {access_token}'
}
).json()
return resj['result']['signInCount']
def get_sign_in_reward(access_token: str, sign_in_count: str) -> str:
"""获取签到奖励"""
resj = requests.post(
'https://member.aliyundrive.com/v1/activity/sign_in_reward?_rx-s=mobile',
json={'signInDay': sign_in_count},
headers={
'Authorization': f'Bearer {access_token}'
}
).json()
return ' *** '.join([resj["result"]["name"], resj["result"]["description"], resj["result"]["notice"]])
def alisignin():
refresh_token = '你的refresh_token'
access_token, user_name = get_token(refresh_token)
if access_token:
sign_in_count = get_sign_in_count(access_token)
print(f'用户名:{user_name} 签到成功,本月累计签到{sign_in_count}次')
info = get_sign_in_reward(access_token, sign_in_count)
print(f'用户名:{user_name} 领取奖励成功,获得 {info}')
today = datetime.datetime.today()
last_day = (relativedelta(months=1) + today).replace(day=1) - relativedelta(days=1)
if today == last_day:
print('已到月底')
for _ in range(1, int(last_day.strftime('%d')) + 1):
info = get_sign_in_reward(access_token, str(_))
print(f'用户名:{user_name} 领取第{_}天奖励成功,获得 {info}')
else:
print('refresh_token异常,获取access_token失败')
if __name__ == '__main__': alisignin()
本文 阿里云盘自动签到-python https://www.itwk.cc/post/906.html 所涉及的软件均源自于网络。
不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。
本站信息来自网络,版权争议与本站无关,您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。
访问和下载本站内容,说明您已同意上述条款。
本站为非盈利性站点,VIP功能仅仅作为用户喜欢本站捐赠打赏功能,本站不贩卖软件,所有内容不作为商业行为。