Skip to content

Commit 578a644

Browse files
fix(route): /zhihu/people/activities/:id (DIYgod#10954)
* Fix zhihu activities * Cleanup code * fix: package & yarn.lock
1 parent 8edc638 commit 578a644

File tree

5 files changed

+621
-9
lines changed

5 files changed

+621
-9
lines changed

lib/v2/zhihu/activities.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
/* eslint-disable no-console */
12
const got = require('@/utils/got');
23
const utils = require('./utils');
34
const { parseDate } = require('@/utils/parse-date');
4-
const md5 = require('@/utils/md5');
5-
const g_encrypt = require('./execlib/g_encrypt');
5+
const g_encrypt = require('./execlib/g_encrypt_3');
6+
const zhihu_hash = require('./execlib/hash.js');
67

78
module.exports = async (ctx) => {
89
const id = ctx.params.id;
@@ -33,16 +34,16 @@ module.exports = async (ctx) => {
3334
const cookie = `d_c0=${cookie_mes}`;
3435

3536
// second: get real data from zhihu
36-
const apiPath = `/api/v4/web_moments/${id}/activities?limit=7&desktop=true`;
37+
const apiPath = `/api/v3/moments/${id}/activities?limit=7&desktop=true`;
3738

3839
// calculate x-zse-96, refer to https://github.com/srx-2000/spider_collection/issues/18
39-
const f = `101_3_2.0+${apiPath}+${cookie_mes}`;
40-
const xzse96 = '2.0_' + g_encrypt(md5(f));
41-
const _header = { cookie, 'x-zse-96': xzse96, 'x-app-za': 'OS=Web', 'x-zse-93': '101_3_2.0' };
40+
const f = `101_3_3.0+${apiPath}+${cookie_mes}`;
41+
const xzse96 = '2.0_' + g_encrypt(zhihu_hash(f));
42+
const _header = { cookie, 'x-zse-96': xzse96, 'x-app-za': 'OS=Web', 'x-zse-93': '101_3_3.0' };
4243

4344
const response = await got({
4445
method: 'get',
45-
url: `https://www.zhihu.com/api/v4/web_moments/${id}/activities?limit=7&desktop=true`,
46+
url: `https://www.zhihu.com/api/v3/moments/${id}/activities?limit=7&desktop=true`,
4647
headers: {
4748
...utils.header,
4849
..._header,

0 commit comments

Comments
 (0)