微信小程序爬虫python_Python爬虫系列之微信小程序逆向某优选爬虫签名算法!厉害...

代码仅供学习交流,请勿用于非法用途

直接上代码

import hashlib

from parser import parseParam

from sign import sign

# 接口秘钥,代码仅供学习,不提供暴露签名

secret = ""

def md5(s):

m = hashlib.md5()

m.update(s.encode("utf-8"))

return str(m.hexdigest()).lower()

def getSign(params, header):

paramStr = ""

if header['content-type'] == "application/x-www-form-urlencoded":

paramStr = parseParam(params)

else:

paramStr = str(params)

return sign(secret, paramStr, header['api-timestamp'])

if __name__ == '__main__':

# application/x-www-form-urlencoded 测试

params = {

"marketingDataQueryReq": '{"spuSns":["20200823000422101803314"],"areaId":10}',

"userKey": "请填写自己的userKey",

}

header = {

"content-type": "application/x-www-form-urlencoded",

"userkey": "请填写自己的userKey",

"api-version": "V3",

"api-sign": "46a2a47696572c2c087e5534a311237a",

"user-agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.15(0x17000f27) NetType/WIFI Language/zh_CN",

"referer": "https://servicewechat.com/wx6025c5470c3cb50c/170/page-frame.html",

"api-timestamp": "1598366897123",

}

sign = getSign(params, header)

print(sign)

# application/json 测试

params = {

"windowId": 45,

"areaId": 10,

"storeId": "66880000000512",

"excludeAct": "N",

"windowType": "ACTIVITY",

"pageSize": 12,

"spuSns": [],

"isFirstRefresh": "TRUE",

"userKey": "请填写自己的userKey"

}

header = {

"content-type": "application/json",

"userkey": "请填写自己的userKey",

"api-version": "V3",

"api-sign": "d4903f86cb0b258d9723f99a68e1d123",

"user-agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.15(0x17000f27) NetType/WIFI Language/zh_CN",

"referer": "https://servicewechat.com/wx6025c5470c3cb50c/170/page-frame.html",

"api-timestamp": "1598366845610",

}

sign = getSign(params, header)

print(sign)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值