- 注册时间
- 2016-4-20
- 最后登录
- 2020-9-12
- 回帖
- 23
- 主题
- 103
- 精华
- 1
- 金币
- 284
- 威望
- 0
- 股份
- 0
- 热心值
- 0
- 积分
- 415
宝藏中专生
- 回帖
- 23
- 金币
- 284
- 威望
- 0
- 积分
- 415
- 股份
- 0
- 热心值
- 0
- 宝藏币
- 0
|
将以下代码按注释复制进SCF云函数中,并修改相应内容即可。
[Python] 纯文本查看 复制代码# !/usr/bin/env python# coding=utf-8import requestsimport timeimport jsonimport sysimport pytzimport datetimefrom io import StringIO# Python版本 3.6,Forked from "https://github.com/lepecoder/checkin"# 请依次修改 29、44、45、50、51行中的需要修改的部分内容# 邀请用户签到可以额外获得会员,每日可邀请最多10个用户,main.py已预置了13个小号用于接受邀请,67-79行信息可选删改# 参考以下代码解决https访问警告# from requests.packages.urllib3.exceptions import InsecureRequestWarning,InsecurePlatformWarning# requests.packages.urllib3.disable_warnings(InsecureRequestWarning)# requests.packages.urllib3.disable_warnings(InsecurePlatformWarning)# 初始化日志sio = StringIO('WPS签到日志\n\n')sio.seek(0, 2) # 将读写位置移动到结尾tz = pytz.timezone('Asia/Shanghai')nowtime = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")sio.write("--------------------------"+nowtime+"----------------------------\n\n")# 微信推送def pushWechat(desp,nowtime): SCKEY = '*********复制SERVER酱的SCKEY进来*************(保留引号)' ssckey = SCKEY send_url='https://sc.ftqq.com/' + ssckey + '.send' params = { 'text': 'WPS小程序签到提醒' + nowtime, 'desp': desp } requests.post(send_url,params=params)# 主函数def main(): # sio.write("\n ===模拟wps小程序签到===") data = { "wps_checkin": [ { "name": "*********请自行输入,仅用于显示*************(保留双引号)", "sid": "*********复制'http://zt.wps.cn'网址Cookie中的sid进来*************(保留双引号)" } ], "wps_invite": [ { "name": "*********请自行输入,仅用于显示*************(保留双引号)", "invite_userid": "*********复制手机WPS个人信息中的用户ID进来,类似括号内容(191641526)*************(不保留双引号)", "sid": [] } ] } sid = data['wps_checkin'] for item in sid: sio.write("\n为{}签到---↓\n\n".format(item['name'])) wps_clockin(item['sid']) # sys.exit() wps_inv = data['wps_invite'] # 这13个账号被邀请 invite_sid = [ "V02StVuaNcoKrZ3BuvJQ1FcFS_xnG2k00af250d4002664c02f", "V02SWIvKWYijG6Rggo4m0xvDKj1m7ew00a8e26d3002508b828", "V02Sr3nJ9IicoHWfeyQLiXgvrRpje6E00a240b890023270f97", "V02SBsNOf4sJZNFo4jOHdgHg7-2Tn1s00a338776000b669579", "V02ScVbtm2pQD49ArcgGLv360iqQFLs014c8062e000b6c37b6", "V02S2oI49T-Jp0_zJKZ5U38dIUSIl8Q00aa679530026780e96", "V02ShotJqqiWyubCX0VWTlcbgcHqtSQ00a45564e002678124c", "V02SFiqdXRGnH5oAV2FmDDulZyGDL3M00a61660c0026781be1", "V02S7tldy5ltYcikCzJ8PJQDSy_ElEs00a327c3c0026782526", "V02SPoOluAnWda0dTBYTXpdetS97tyI00a16135e002684bb5c", "V02Sb8gxW2inr6IDYrdHK_ywJnayd6s00ab7472b0026849b17", "V02SwV15KQ_8n6brU98_2kLnnFUDUOw00adf3fda0026934a7f", "V02SC1mOHS0RiUBxeoA8NTliH2h2NGc00a803c35002693584d" ] sio.write("\n\n==========wps邀请==========\n\n") for item in wps_inv: sio.write("为{}邀请---↓\n\n".format(item['name'])) wps_invite(invite_sid, item['invite_userid']) desp = sio.getvalue() pushWechat(desp,nowtime) return desp# wps接受邀请def wps_invite(sid: list, invite_userid: int) -> None: invite_url = 'http://zt.wps.cn/2018/clock_in/api/invite' s = requests.session() for index, i in enumerate(sid): headers = { 'sid': i } r = s.post(invite_url, headers=headers, data={ 'invite_userid': invite_userid}) sio.write("ID={}, 状态码: {}, \n\n 请求信息{}\n\n".format(str(index+1).zfill(2), r.status_code, r.text))# wps签到def wps_clockin(sid: str) -> None: getquestion_url = 'http://zt.wps.cn/2018/clock_in/api/get_question?member=wps' s = requests.session() # 打卡签到需要参加活动 r = s.get(getquestion_url, headers={'sid': sid}) ''' { "result": "ok", "data": { "multi_select": 1, "options": [ "30天文档分享链接有效期", "远程下载助手", "输出长图片去水印", "PDF转图片" ], "title": "以下哪些特权是WPS会员和超级会员共同拥有的?" }, "msg": "" } ''' answer_set = { 'WPS会员全文检索', '100G', 'WPS会员数据恢复', 'WPS会员PDF转doc', 'WPS会员PDF转图片', 'WPS图片转PDF插件', '金山PDF转WORD', 'WPS会员拍照转文字', '使用WPS会员修复', 'WPS全文检索功能', '有,且无限次', '文档修复' } resp = json.loads(r.text) # sio.write(resp['data']['multi_select']) # 只做单选题 multi_select==1表示多选题 while resp['data']['multi_select'] == 1: r = s.get(getquestion_url, headers={'sid': sid}) resp = json.loads(r.text) # sio.write(resp['data']['multi_select']) answer_id = 3 for i in range(4): opt = resp['data']['options'] if opt in answer_set: answer_id = i+1 break sio.write("选项: {}\n\n".format(resp['data']['options'])) sio.write("选择答案: {}\n\n".format(answer_id)) answer_url = 'http://zt.wps.cn/2018/clock_in/api/answer?member=wps' # 提交答案 r = s.post(answer_url, headers={'sid': sid}, data={'answer': answer_id}) resp = json.loads(r.text) # 答案错误 if resp['msg'] == 'wrong answer': sio.write("答案不对,挨个尝试\n\n") for i in range(4): r = s.post(answer_url, headers={'sid': sid}, data={'answer': i+1}) resp = json.loads(r.text) sio.write(i+1) if resp['result'] == 'ok': sio.write(r.text) break # 打卡签到 clockin_url = 'http://zt.wps.cn/2018/clock_in/api/clock_in?member=wps' r = s.get(clockin_url, headers={'sid': sid}) sio.write("签到信息: {}\n\n".format(r.text)) resp = json.loads(r.text) # 重新报名 if resp['msg'] == '前一天未报名': sio.write('前一天未报名,报名后第二天签到\n\n') signup_url = 'http://zt.wps.cn/2018/clock_in/api/sign_up' r=s.get(signup_url, headers={'sid': sid}) sio.write(r.text)def main_handler(event, context): return main()if __name__ == '__main__': main() |
|