当前位置:AIGC资讯 > 数据采集 > 正文

Python爬虫系列之微信小程序兴盛优选爬虫签名算法

Python爬虫系列之微信小程序兴盛优选爬虫签名算法

小程序爬虫接单、app爬虫接单、网页爬虫接单、接口定制、网站开发、小程序开发> 点击这里联系我们 <

最新版算法+云盾已经成功破解

微信请扫描下方二维码

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

直接上代码

import hashlib
from parser import parse
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 = parse(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)

更新时间 2023-11-08