网友scp-173分享:
"timestamp" 和"requestDate" 改为要抢场次的开场时间 如"2021-1-28 10:00:00"
start_time 是脚本开始运行的时间
默认循环500次 0.1s一次
开着抓包软件进入30-20 券的那个会场
会出现 https://mapi.bestpay.com.cn/mapi … asStationCouponList 这条数据
抓出来的数据填到cookies里面
其中 "couponNo":这条在 响应的预览里面
其他的cookies数据 在 请求的预览 里面
- import requests
- from datetime import datetime
- import time
- # from bs4 import BeautifulSoup
- url = "https://mapi.bestpay.com.cn/mapi/redbag/lifeGasStation/drawCoupon"
- start_time = "2021-1-28 09:59:55"
- sleeptime = 0.9
- timeArray = datetime.strptime(start_time, "%Y-%m-%d %H:%M:%S")
- def time_server():
- #获得京东服务器时间
- #r1 = requests.get(‘https://a.jd.com//ajax/queryServerData.html’).json()[‘serverTime’]
- # 获取本地服务器的时间戳
- r1 = time.time()*1000#获当前时间的时间戳
- # 把时间戳格式/1000 获取毫秒
- timeNum = int(r1) / 1000
- # 格式化时间 (小数点后6为)
- time1 = datetime.fromtimestamp(timeNum)
- return time1
- headers = {
- "Host": "mapi.bestpay.com.cn",
- "Connection": "keep-alive",
- "Content-Length": "606",
- "Accept": "application/json, text/plain, */*",
- "Origin": "https://h5.bestpay.cn",
- "User-Agent": "Mozilla/5.0 (Linux; Android 9; Redmi K20 Pro Premium Edition Build/PKQ1.190616.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.136 Mobile Safari/537.36 Bestpay/10.1.61 hybridVersion/3.0",
- "Content-Type": "application/json;charset=UTF-8",
- "Referer": "https://h5.bestpay.cn/subapps/bestpaymall-client-h5/january/main.html?isOutIn=true&hybridVersion=3.0&pageFrom=weijinwei",
- "Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
- "X-Requested-With": "com.chinatelecom.bestpayclient"
- }
- cookies = {
- "loginChannel": "App",
- "couponNo":
- "token":
- "keep":
- "agreeId":
- "timestamp":
- "requestDate":
- "fromchannelId":
- "method":
- "productNo":
- "channel":
- "loginNo":
- "tradeChannel":
- "traceLogId":
- "sessionKey":
- "appType":"",
- "sign":
- "getEncInfo":
- }
- #session = requests.post(url=url, headers=headers, json=cookies)
- #print(session.text)
- def refresh():
- seconds = (time_server() – datetime.now()).microseconds
- timedifference = 2-(seconds/1000000)
- while True:
- # 判断时间服务器时间是否大于或等于开始的时间
- if datetime.now() >=timeArray:
- time.sleep(timedifference-sleeptime)
- session = requests.post(url=url, headers=headers, json=cookies)
- print(session.text)
- print(time_server())
- #print(datetime.now())
- print("任务开始")
- for i in range(500):
- time.sleep(0.1)
- session = requests.post(url=url, headers=headers, json=cookies)
- print(session.text)
- print(time_server())
- #print(datetime.now())
- print("任务完成")
- break
- refresh()
- print("————-ok————-")
复制代码
网友mj1234分享:
mk
网友htomza分享:
mk
网友yjss135分享:
1
网友wenfuyu分享:
mark
网友wwang_ll分享:
技术贴必须果
网友xukesky11分享:
在手机还是电脑抓包
网友xiaoye1398分享:
完全看不懂
网友xb340分享:
mk
网友zzk951分享:
1
网友XYLZ786分享:
mk
网友gubin686222分享:
mk