From 24c83b189dcf5a9d195c6a8afa7d6cdfa48eee7e Mon Sep 17 00:00:00 2001 From: GamerNoTitle Date: Sat, 21 Nov 2020 19:59:34 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AD=BE=E5=88=B0post=E6=9E=84=E9=80=A0?= =?UTF-8?q?=E5=AE=8C=E6=88=90(=E6=9C=AA=E6=8A=95=E5=85=A5=E4=BD=BF?= =?UTF-8?q?=E7=94=A8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 51be0f3..214728f 100644 --- a/main.py +++ b/main.py @@ -2,11 +2,11 @@ import sys import requests as r import json -sign='' +sign='https://n.cg.163.com/api/v2/sign-today' current='https://n.cg.163.com/api/v2/client-settings/@current' cookie=sys.argv[1] -header={ +getheader={ 'Host': 'n.cg.163.com', 'Connection': 'keep-alive', 'Accept': 'application/json, text/plain, */*', @@ -22,15 +22,36 @@ header={ 'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,ja-JP;q=0.6,ja;q=0.5' } -def post(url,data,header): +signheader={ + 'Accept': 'application/json, text/plain, */*', + 'Accept-Encoding': 'gzip, deflate, br', + 'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,ja-JP;q=0.6,ja;q=0.5', + 'Authorization': cookie, + 'Connection': 'keep-alive', + 'Content-Length': '0', + 'Host': 'n.cg.163.com', + 'Origin': 'https://cg.163.com', + 'Referer': 'https://cg.163.com/', + '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/86.0.4240.198 Safari/537.36', + 'X-Platform': '0' +} + +def post(url,header): result=r.post(url=url,headers=header) return result -def getme(url,data,header): +def getme(url,header): result=r.get(url=url,headers=header) print(result) return result if __name__ == "__main__": - me=getme(current,None,header) - print(me.text) \ No newline at end of file + me=getme(current,getheader) + print(me.text,end='\n') + signin=post(sign,signheader) + print(signin.text,end='\n') + print(signin.status_code) + \ No newline at end of file