python代码:

import urllib
import requests
from py_mini_racer import MiniRacer
import hashlib
import execjs
import json
import time
from urllib.parse import urlparse

d_co = 'AJDWnZsqnxWPThsPHCtfo2a8YYdYSZ-bLv0=|1664238731'
version = '101_3_3.0'
path = '/remix/well/1419263074604343296/catalog?offset=10&limit=13&order_by=global_idx&is_new_column=true'
cookies = {
    'd_c0': d_co,
}


def get_x_zse_96(val):
    m = hashlib.md5()

    m.update(val.encode('utf-8'))

    with open('zhihuvmp.js', 'r') as s:
        ctx1 = execjs.compile(s.read(), cwd=r'/usr/local/lib/node_modules')
    encrypt_str = ctx1.call('get_zse_96', m.hexdigest())
    return encrypt_str

    # js_code = open('zhihuvmp.js', encoding='utf-8').read()
    # ctx = MiniRacer()
    # ctx.eval(js_code)
    # result = ctx.call('get_zse_96', m.hexdigest())
    # return result


def get_page_list(url):
    val = f'{version}+{path}+{d_co}'
    headers = {
        "accept-encoding": "gzip, deflate, br",
        "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,fr;q=0.7,zh-TW;q=0.6,ja;q=0.5",
        "origin": "https://www.zhihu.com",
        "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36",
        "x-zse-93": version,
        "x-zse-96": get_x_zse_96(val),
    }
    url = "https://api.zhihu.com/remix/well/1419263074604343296/catalog"

    params = {
        "offset": 10,
        "limit": 13,
        "order_by": "global_idx",
        "is_new_column": "true"
    }

    pid = '1419263074604343296'
    response = requests.get(url, params=params, cookies=cookies, headers=headers)
    with open(f'{pid}-2.txt', 'w', encoding='utf-8') as f:
        f.write(json.dumps(response.json()))

    print(response.json())
    return response.json()


def parse_json(_url):
    paid = '1419263074604343296'
    with open(f'{paid}-2.txt', "r") as f:
        json_data = json.load(f)

    # json_data = json.loads(data)
    # print(json.dumps(json_data, indent=2))  # 将JSON代码格式化输出

    # app_context = json_data.get('appContext')
    # print(json.dumps(app_context, indent=2))

    catalog_data = json_data.get('data')
    seq = 1
    column_id = 2
    if catalog_data:
        for section in catalog_data:  # 迭代catalogData中的每个元素
            section_title = section['title']  # 获取每个元素的标题
            section_chapter = section['index']['serial_number_txt']
            title = section_chapter + section_title
            seid = section['id']
            file_path = f"/{paid}/{seid}.txt"
            createtime = int(time.time())
            # print(f"章节标题:{title} {section_title},url:")
            # print(f"https://www.zhihu.com/market/paid_column/{paid}/section/{seid}")
            # query = "INSERT INTO fa_novel_section (column_id, paid, seid, seq, title, file_path, createtime) VALUES (%s, %s, %s, %s, %s, %s, %s)"
            query = f"INSERT INTO fa_novel_section (column_id, paid, seid, seq, title, file_path, createtime) VALUES ({column_id}, '{paid}', '{seid}', {seq}, '{title}', '{file_path}', {createtime})"
            print(query)
            seq += 1


    else:
        print("未找到name属性")


if __name__ == '__main__':
    url = 'https://www.zhihu.com/xen/market/remix/paid_column/1609560969377628160?is_share_data=true'
    # get_page_list(url)

    parse_json(url)


def parse_pid(_url):
    parsed_url = urlparse(_url)
    path = parsed_url.path
    column_id = path.rsplit('/', 1)[-1]
    return column_id

js文件:

let init_str = "6fpLRqJO8M/c3jnYxFkUVC4ZIG12SiH=5v0mXDazWBTsuw7QetbKdoPyAl+hN9rgE";
var h = {
    zk: [1170614578, 1024848638, 1413669199, -343334464, -766094290, -1373058082, -143119608, -297228157, 1933479194, -971186181, -406453910, 460404854, -547427574, -1891326262, -1679095901, 2119585428, -2029270069, 2035090028, -1521520070, -5587175, -77751101, -2094365853, -1243052806, 1579901135, 1321810770, 456816404, -1391643889, -229302305, 330002838, -788960546, 363569021, -1947871109],
    zb: [20, 223, 245, 7, 248, 2, 194, 209, 87, 6, 227, 253, 240, 128, 222, 91, 237, 9, 125, 157, 230, 93, 252, 205, 90, 79, 144, 199, 159, 197, 186, 167, 39, 37, 156, 198, 38, 42, 43, 168, 217, 153, 15, 103, 80, 189, 71, 191, 97, 84, 247, 95, 36, 69, 14, 35, 12, 171, 28, 114, 178, 148, 86, 182, 32, 83, 158, 109, 22, 255, 94, 238, 151, 85, 77, 124, 254, 18, 4, 26, 123, 176, 232, 193, 131, 172, 143, 142, 150, 30, 10, 146, 162, 62, 224, 218, 196, 229, 1, 192, 213, 27, 110, 56, 231, 180, 138, 107, 242, 187, 54, 120, 19, 44, 117, 228, 215, 203, 53, 239, 251, 127, 81, 11, 133, 96, 204, 132, 41, 115, 73, 55, 249, 147, 102, 48, 122, 145, 106, 118, 74, 190, 29, 16, 174, 5, 177, 129, 63, 113, 99, 31, 161, 76, 246, 34, 211, 13, 60, 68, 207, 160, 65, 111, 82, 165, 67, 169, 225, 57, 112, 244, 155, 51, 236, 200, 233, 58, 61, 47, 100, 137, 185, 64, 17, 70, 234, 163, 219, 108, 170, 166, 59, 149, 52, 105, 24, 212, 78, 173, 45, 0, 116, 226, 119, 136, 206, 135, 175, 195, 25, 92, 121, 208, 126, 139, 3, 75, 141, 21, 130, 98, 241, 40, 154, 66, 184, 49, 181, 46, 243, 88, 101, 183, 8, 23, 72, 188, 104, 179, 210, 134, 250, 201, 164, 89, 216, 202, 220, 50, 221, 152, 140, 33, 235, 214]

};

function i(e, t, n) {
    t[n] = 255 & e >>> 24,
        t[n + 1] = 255 & e >>> 16,
        t[n + 2] = 255 & e >>> 8,
        t[n + 3] = 255 & e
}

function Q(e, t) {
    return (4294967295 & e) << t | e >>> 32 - t
}

function B(e, t) {
    return (255 & e[t]) << 24 | (255 & e[t + 1]) << 16 | (255 & e[t + 2]) << 8 | 255 & e[t + 3]
}

function G(e) {
    var t = new Array(4)
        , n = new Array(4);
    i(e, t, 0),
        n[0] = h.zb[255 & t[0]],
        n[1] = h.zb[255 & t[1]],
        n[2] = h.zb[255 & t[2]],
        n[3] = h.zb[255 & t[3]];

    var r = B(n, 0);
    return r ^ Q(r, 2) ^ Q(r, 10) ^ Q(r, 18) ^ Q(r, 24)
}

function array_0_16_offset(e) {
    var t = new Array(16)
        , n = new Array(36);
    n[0] = B(e, 0),
        n[1] = B(e, 4),
        n[2] = B(e, 8),
        n[3] = B(e, 12);
    for (var r = 0; r < 32; r++) {
        var o = G(n[r + 1] ^ n[r + 2] ^ n[r + 3] ^ h.zk[r]);
        n[r + 4] = n[r] ^ o
    }
    return i(n[35], t, 0),
        i(n[34], t, 4),
        i(n[33], t, 8),
        i(n[32], t, 12),
        t

}

function array_16_48_offset(e, t) {
    for (var n = [], r = e.length, i = 0; 0 < r; r -= 16) {
        for (var o = e.slice(16 * i, 16 * (i + 1)), a = new Array(16), c = 0; c < 16; c++)
            a[c] = o[c] ^ t[c];
        t = array_0_16_offset(a),
            n = n.concat(t),
            i++
    }
    return n
}

function encode_0_16(array_0_16) {
    let result = [];
    let array_offset = [48, 53, 57, 48, 53, 51, 102, 55, 100, 49, 53, 101, 48, 49, 100, 55];
    for (let i = 0; i < array_0_16.length; i++) {
        let a = array_0_16[i] ^ array_offset[i],
            b = a ^ 42;
        result.push(b)
    }
    return array_0_16_offset(result)
}

function encode(ar) {
    let b = ar[1] << 8,
        c = ar[0] | b,
        d = ar[2] << 16,
        e = c | d,
        result_array = [],
        x6 = 6;
    result_array.push(e & 63);
    while (result_array.length < 4) {
        let a = e >>> x6;
        result_array.push(a & 63);
        x6 += 6;
    }
    return result_array
}

function get_init_array(encode_md5) {
    let init_array = []
    for (let i = 0; i < encode_md5.length; i++) {
        init_array.push(encode_md5.charCodeAt(i))
    }
    init_array.unshift(0)
    init_array.unshift(Math.floor(Math.random() * 127))
    while (init_array.length < 48) {
        init_array.push(14)
    }
    let array_0_16 = encode_0_16(init_array.slice(0, 16)),
        array_16_48 = array_16_48_offset(init_array.slice(16, 48), array_0_16),
        array_result = array_0_16.concat(array_16_48);
    return array_result
}

function get_zse_96(encode_md5) {
    let result_array = [],
        init_array = get_init_array(encode_md5),
        result = "";
    for (let i = 47; i >= 0; i-=4) {
        init_array[i] ^= 58
    }
    init_array.reverse()
    for (let j = 3; j <= init_array.length; j+=3) {
        let ar = init_array.slice(j - 3, j);
        result_array = result_array.concat(encode(ar))
    }
    for (let index = 0; index < result_array.length; index++) {
        result += init_str.charAt(result_array[index])
    }
    result='2.0_'+result
    return result
}

let encode_md5 = "96a98c8b3a433d47b4d9070273330be2";
console.log(get_zse_96(encode_md5));