1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
| import requests import os if __name__ == '__main__': COOKIE = os.environ["COOKIE"] USERNAME = os.environ["USERNAME"] DDSECRET = os.environ["DDSECRET"] DDPOSTURL = os.environ["DDPOSTURL"]
headers = { 'accept': 'application/json, text/plain, */*', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8', 'content-length': '246', 'content-type': 'application/json;charset=UTF-8', 'cookie': COOKIE, 'origin': 'https://i.csdn.net', 'referer': 'https://i.csdn.net/', 'sec-ch-ua': '"Chromium";v="88", "Google Chrome";v="88", ";Not A Brand";v="99"', 'sec-ch-ua-mobile': '?0', 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'same-site', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36' }
data = { 'ip': '', 'platform': 'pc-my', 'product': 'pc', 'user_agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36', 'username': USERNAME, 'uuid': '10_10212595300-1608558661367-119405', }
r = requests.post("https://me.csdn.net/api/LuckyDraw_v2/signIn",headers=headers,data=data).content.decode("unicode_escape") print(r) import json timedata = json.loads(r)
print(timedata) message = timedata['message'] isSign = timedata['data']['isSigned']
t = timedata['data']['msg'] print(t)
import time import hmac import hashlib import base64 import urllib.parse import requests, json
timestamp = str(round(time.time() * 1000)) secret = DDSECRET secret_enc = secret.encode('utf-8') string_to_sign = '{}\n{}'.format(timestamp, secret) string_to_sign_enc = string_to_sign.encode('utf-8') hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest() sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
headers = {'Content-Type': 'application/json'}
webhook = DDPOSTURL + timestamp + "&sign=" + sign
if message == '成功': data = { "msgtype": "markdown", "markdown": { "title":"CSDN签到通知", "text": ">CSDN 签到已成功\n - 签到详情:" + t + "\n------------⭐项目地址:[https://github.com/Rr210/qiandao](https://github.com/Rr210/qiandao)" } } res = requests.post(webhook, data=json.dumps(data), headers=headers) print(res.text) else: data = { "msgtype": "markdown", "markdown": { "title": "CSDN签到通知", "text": ">CSDN 签到失败\n - 签到详情:"+ timedata + "\n项目地址:[https://github.com/Rr210/qiandao](https://github.com/Rr210/qiandao)" } } res = requests.post(webhook, data=json.dumps(data), headers=headers) print(res.text)
|