JS逆向爬虫---响应结果加密⑤【token参数加密与DES解密】

https://spa7.scrape.center/

文本数据

数据内嵌在js内,普通合理请求即可获取
JS逆向爬虫---响应结果加密⑤【token参数加密与DES解密】_第1张图片

图片

位于固定接口
类似https://spa7.scrape.center/img/durant.png 固定url+名称
JS逆向爬虫---响应结果加密⑤【token参数加密与DES解密】_第2张图片

Token

JS逆向爬虫---响应结果加密⑤【token参数加密与DES解密】_第3张图片

参数确定

base64Name
==> base64编码后的中文名称
nodejs 代码

//导入crypto-js模块
var CryptoJS = require("crypto-js");
var start_key = 'fipFfVsZsTda94hJNKJfLoaqyqMZFFimwLt'
var key = CryptoJS.enc.Utf8.parse(start_key)

// 加密函数
function encryptByDES(base64name, birthday, height, weight) {
    var srcs = CryptoJS.enc.Utf8.parse(base64name + birthday + height + weight);
    var encrypted = CryptoJS.DES.encrypt(srcs, key, {
        mode: CryptoJS.mode.ECB,
        padding: CryptoJS.pad.Pkcs7
    });
    return encrypted.toString();
}

python逆向实现

# coding=utf-8

import base64
import execjs
# 生成token

name = "凯文-杜兰特"
birthday = "1988-09-29"
height = "208cm"
weight = "108.9KG"
# base64编码数据
name_base64 = base64.b64encode(name.encode('utf-8')).decode('utf-8')

# 调用token.js的encryptByDES方法
ctx = execjs.compile(open('token.js', 'r', encoding='gbk').read())

# 生成token
result = ctx.call('encryptByDES', name_base64, birthday, height, weight)
print(result)
# DG1uMMq1M7OeHhds71HlSMHOoI2tFpWCB4ApP00cVFqptmlFKjFu9RluHo2w3mUw
# DG1uMMq1M7OeHhds71HlSMHOoI2tFpWCB4ApP00cVFqptmlFKjFu9RluHo2w3mUw

你可能感兴趣的:(python爬虫综合,javascript,爬虫,开发语言,python)