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