forked from Fragrance/maquitous
feat: move requests to httpx
This commit is contained in:
parent
fd2f93e937
commit
0d27140dee
@ -1,4 +1,4 @@
|
||||
requests
|
||||
httpx
|
||||
pycryptodome
|
||||
pytz
|
||||
flask
|
||||
|
36
sdgb.py
36
sdgb.py
@ -3,7 +3,7 @@ import zlib
|
||||
import pytz
|
||||
import base64
|
||||
import hashlib
|
||||
import requests
|
||||
import httpx
|
||||
|
||||
from datetime import datetime
|
||||
from Crypto.Cipher import AES
|
||||
@ -29,7 +29,6 @@ class aes_pkcs7(object):
|
||||
|
||||
def decrypt(self, content):
|
||||
cipher = AES.new(self.key, AES.MODE_CBC, self.iv)
|
||||
#content = base64.b64decode(content)
|
||||
return cipher.decrypt(content)
|
||||
text = cipher.decrypt(content).decode('utf-8')
|
||||
return self.pkcs7unpadding(text)
|
||||
@ -56,26 +55,26 @@ def sdgb_api(data, useApi, userId):
|
||||
data = data
|
||||
data_enc = aes.encrypt(data)
|
||||
data_def = zlib.compress(data_enc)
|
||||
requests.packages.urllib3.disable_warnings()
|
||||
endpoint = "https://maimai-gm.wahlap.com:42081/Maimai2Servlet/"
|
||||
r = requests.post(endpoint + get_hash_api(useApi), headers={
|
||||
"User-Agent": "%s#%d"%(get_hash_api(useApi), userId),
|
||||
"Content-Type": "application/json",
|
||||
"Mai-Encoding": "1.40",
|
||||
"Accept-Encoding": "",
|
||||
"Charset": "UTF-8",
|
||||
"Content-Encoding": "deflate",
|
||||
"Expect": "100-continue"
|
||||
}, data = data_def,verify=False)
|
||||
r = httpx.post(
|
||||
endpoint + get_hash_api(useApi),
|
||||
headers = {
|
||||
"User-Agent": "%s#%d"%(get_hash_api(useApi), userId),
|
||||
"Content-Type": "application/json",
|
||||
"Mai-Encoding": "1.40",
|
||||
"Accept-Encoding": "",
|
||||
"Charset": "UTF-8",
|
||||
"Content-Encoding": "deflate",
|
||||
"Expect": "100-continue"
|
||||
},
|
||||
data = data_def
|
||||
)
|
||||
resp_def = r.content
|
||||
|
||||
try:
|
||||
resp_enc = zlib.decompress(resp_def)
|
||||
#print(resp_enc)
|
||||
except:
|
||||
resp_enc = resp_def
|
||||
#print("skipped")
|
||||
#print(resp_enc)
|
||||
return unpad(aes.decrypt(resp_enc), 16).decode()
|
||||
|
||||
def qr_api(qr_code):
|
||||
@ -96,7 +95,10 @@ def qr_api(qr_code):
|
||||
"Host": "ai.sys-all.cn",
|
||||
"User-Agent": "WC_AIME_LIB"
|
||||
}
|
||||
res = requests.post("http://ai.sys-allnet.cn/wc_aime/api/get_data", data=json.dumps(param, separators=(',', ':')), headers=headers)
|
||||
# print(param) # debug打印param数据
|
||||
res = httpx.post(
|
||||
"http://ai.sys-allnet.cn/wc_aime/api/get_data",
|
||||
data = json.dumps(param, separators=(',', ':')),
|
||||
headers = headers
|
||||
)
|
||||
assert res.status_code == 200, "网络错误"
|
||||
return json.loads(res.content)
|
Loading…
x
Reference in New Issue
Block a user