本帖最后由 fire9 于 2024-7-30 16:10 编辑
import requests
import time
import hashlib
import warnings
warnings.filterwarnings("ignore")
round = '16:00' #todo 自己改
def generate_sign(secretword,timestamp):
# 构造字符串marketingId=1816854086004391938&round=18:00&s=2&secretword=7&stamp=1722248190033c274bac6493544b89d9c4f9d8d542b84
marketingId = '1816854086004391938'
s = '2'
stamp = timestamp
sign_str = f'marketingId={marketingId}&round={round}&s={s}&secretword={secretword}&stamp={stamp}c274bac6493544b89d9c4f9d8d542b84'
sign = hashlib.md5(sign_str.encode('utf-8')).hexdigest()
print(sign_str)
return sign
# 毫秒级时间戳
def get_timestamp():
return str(time.time() * 1000)
def send_request(secretword,timestamp):
headers = {
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
'Access-Token': '', # todo 自己改
'Cache-Control': 'no-cache',
'Connection': 'keep-alive',
'Content-Type': 'application/json;charset=UTF-8',
'Origin': 'https://mxsa-h5.mxbc.net',
'Pragma': 'no-cache',
'Referer': 'https://mxsa-h5.mxbc.net/',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-site',
'User-Agent': 'Mozilla/5.0 (Linux; Android 11; PDRM00 Build/RKQ1.200903.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.178 Mobile Safari/537.36mxsa_mxbc',
'X-Requested-With': 'com.mxbc.mxsa',
'sec-ch-ua': '"Not A(Brand";v="99", "Android WebView";v="121", "Chromium";v="121"',
'sec-ch-ua-mobile': '?1',
'sec-ch-ua-platform': '"Android"',
}
json_data = {
'marketingId': '1816854086004391938',
'round': round,
'secretword': secretword,
'sign': generate_sign(secretword,timestamp),
's': 2,
'stamp': timestamp,
}
response = requests.post('https://mxsa.mxbc.net/api/v1/h5/marketing/secretword/confirm', headers=headers, json=json_data, verify=False,timeout=1)
print(response.text)
response.close()
if __name__ == '__main__':
secretword = "茉莉奶绿销量突破500万杯"
for i in range(30):
timestamp = get_timestamp()
send_request(secretword,timestamp)
time.sleep(0.8)
|