import hashlib
import json
import time
from pip._vendor import requests
a = '加密字符串'
t=str(int(time.time()))
sign=a+str(t)
m = hashlib.md5()
m.update(sign.encode("utf8"))
a_md5 = m.hexdigest()
headers = {
"token" :"登录之后的token信息",
"User-Agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_2_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.18(0x1800122c) NetType/WIFI Language/zh_CN",
"Accept-Encoding":"gzip",
"Accept-Language":"zh-CN,zh;q=0.9",
"Content-Type":"application/json",
"Content-Length":"129",
"time":t,
"sign":a_md5
}
data={
"lotteryActivitySendId":"75",
"openId":"小程序openid",
"codeCount":1
}
n = 0
while n < 21:
# 抽奖接口
url = "抽奖接口"
luckyUrl = requests.post(url=url, data=json.dumps(data),headers=headers)
print(luckyUrl)
with open('C:/Users/Lenovo/Desktop/choujiang/choujiang.txt', 'a+', encoding='utf-8') as f:
print(luckyUrl.text, file=f)
print('--------------------\n', file=f)
print("这是第"+str(n+1) +"次")
n+=1
python调用抽奖接口,实现多次抽奖
于 2022-02-23 14:07:13 首次发布