提前申明:
这篇文章只用于作者个人记录,学习,任何人不得转载、分享。不转发不扩散,如因此造成的任何损失或其他影响,本人概不承担。
抓包
一般银行的app都会对抓包工具进行检测。首先我们先打开抓包工具,然后去app里进行签到。
会提示签到成功,然后再去抓包工具里获取响应数据。
{
"errMsg": "",
"data": {
"GIFT_BAG": [
{
"couponId": "jUwxPMcDGV0/J9vqesx9dtdjnx4/Dnmr",
"couponInstanceId": null,
"couponType": 1,
"nodeDay": 7,
"couponName": "连续7天签到满48元减10元美团外卖优惠券",
"dccpBscInfSn": "000028",
"couponImg": "http://imageadv.ccb.com/adpic/nctm/qy/20240828/1020120051724842309364711.png",
"couponPrice": 10,
"couponBuyPrice": 0,
"couponScene": "外卖",
"title": "10元 美团外卖券",
"subTitle": "限天天神券商户 满48元可用"
},
{
"couponId": "jUwxPMcDGV3RVMQlOr1m3ddjnx4/Dnmr",
"couponInstanceId": null,
"couponType": 1,
"nodeDay": 7,
"couponName": "连续7天签到满40元减10元饿了么外卖优惠券",
"dccpBscInfSn": "000028",
"couponImg": "http://imageadv.ccb.com/adpic/nctm/qy/20240828/1020120051724841160358441_1.png",
"couponPrice": 10,
"couponBuyPrice": 0,
"couponScene": "外卖",
"title": "10 元饿了么外卖券",
"subTitle": "限指定商户满40 元可用"
},
{
"couponId": "jUwxPMcDGV2hwtCl4K9NpNdjnx4/Dnmr",
"couponInstanceId": null,
"couponType": 1,
"nodeDay": 7,
"couponName": "连签7天满49元减10元美团外卖券(限商超便利)",
"dccpBscInfSn": "000028",
"couponImg": "http://imageadv.ccb.com/adpic/nctm/qy/20240828/1020120011724842478380177.png",
"couponPrice": 10,
"couponBuyPrice": 0,
"couponScene": "外卖",
"title": "10元 美团外卖券",
"subTitle": "限商超便利商户 满49元可用"
}
],
"SIGN_REQ": 1,
"SIGN_TIPS": "签到礼包",
"NEXT_IMG": null,
"NEST_AWARD_DAY": 1,
"IS_AWARD": 0
},
"reqFlowNo": "1051004351732755986064200",
"errCode": "0"
}
可以看到我们请求的接口地址为:https://yunbusiness.ccb.com/clp_coupon/txCtrl?txcode=A3341A139
在最开始的时候,其实写一个post请求就可以完成自动签到了。但是后期建行生活改了接口参数,当前获取的cookie有效时长只有半个小时。因为我们,每次进行签到前,要重新获取cookie。然后拿到cookie在进行签到。
模拟登录拿到cookie
def get_session_value(headers, payload):
session_url = "https://yunbusiness.ccb.com/clp_service/txCtrl?txcode=autoLogin"
response = requests.post(url=session_url, headers=headers, data=payload)
session_cookie = response.headers.get('Set-Cookie')
session_start = session_cookie.find("SESSION=") + len("SESSION=")
session_end = session_cookie.find(";", session_start)
session_value = session_cookie[session_start:session_end]
return session_value
拿到cookie后,就可以直接进行签到。
签到
def mian():
headers = {
"Host": "yunbusiness.ccb.com",
"clientInfo": "固定值自己抓取",
"User-Agent": "%E5%BB%BA%E8%A1%8C%E7%94%9F%E6%B4%BB/2024051001 CFNetwork/1496.0.7 Darwin/23.5.0",
"MID": "161",
"functionId": "10000078",
"DeviceType": "iOS",
"MBC-User-Agent": "固定值自己抓取",
"AppVersion": "2.1.8.001",
"UA": "IPHONE",
"CHANNEL_NUM": "2",
"clientAllVer": "2.1.8.001",
"MBSKEY_INFO": "固定值自己抓取",
"nsdsid": "固定值自己抓取",
"Content-Length": "378",
"MBC-User-Info": "固定值自己抓取",
"DeviceId": "固定值自己抓取",
"Connection": "keep-alive",
"Accept-Language": "zh-CN,zh-Hans;q=0.9",
"C-App-Id": "固定值自己抓取",
"Accept": "application/json",
"Content-Type": "application/json",
"Accept-Encoding": "gzip, deflate, br",
"mbc_user_info": "固定值自己抓取"
}
payload = "固定值自己抓取"
## 这里就是模拟登录拿到session 然后进行组装
session = get_session_value(headers, payload)
headers['Cookie'] = str("SESSION=" + session )
data = {
"APPEND_PARAM": "固定值自己抓取",
"sign": "固定值自己抓取",
"chnlType": "1",
"ACT_ID": "固定值自己抓取",
"REGION_CODE": "固定值自己抓取",
"regionCode": "固定值自己抓取"
}
response = requests.post(url=url, headers=headers, data=json.dumps(data))
# 获取JSON响应
json_data = response.json()
print(json_data)
此时此刻,签到就算完成了,但是我们只是签到了,要拿到自己的优惠券。可以在签到后获取的code进行模拟。
def signin_nodeCoupon(headers):
signin_url = 'https://yunbusiness.ccb.com/clp_coupon/txCtrl?txcode=A3341C120'
nodeCoupon = ''
today = datetime.datetime.now().date()
weekday = today.weekday()
if weekday == 2:
# 第三天签到
print("今天是星期三")
nodeCoupon = {
"actId": "固定值自己抓取",
"regionCode": "固定值自己抓取",
"dccpBscInfSn": "",
"APPEND_PARAM": "固定值自己抓取",
"couponType": 0,
"nodeCouponId": "ysx3lNxfHnI=(商品code)",
"nodeDay": 3,
"chnlType": "1"
}
elif weekday == 6:
# 第七天签到
print("今天是星期日")
nodeCoupon = {
"actId" : "固定值自己抓取",
"regionCode" : "固定值自己抓取",
"dccpBscInfSn" : "",
"APPEND_PARAM" : "固定值自己抓取",
"couponType" : 0,
"nodeCouponId" : "4E/YHcbD5zs=(商品code)",
"nodeDay" : 7,
"chnlType" : "1"
}
if nodeCoupon == '':
return
response = requests.post(signin_url, headers=headers, data=json.dumps(nodeCoupon))
# 获取JSON响应
json_data = response.json()
print(json_data)
# if json_data['errCode'] != '0':
# send("建行生活优惠券", json_data)
因此签到脚本就算ok了。然后挂上青龙面板定时执行就可以了。