From 72d1f85d2ffdf09bf847e4b3bce79e7b08ed8f68 Mon Sep 17 00:00:00 2001 From: 15532 <37644685+15532@users.noreply.github.com> Date: Tue, 25 Jun 2024 01:32:01 +0800 Subject: [PATCH] fix(route): fetch zhihu column info with signed header (#15982) --- lib/routes/zhihu/zhuanlan.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/routes/zhihu/zhuanlan.ts b/lib/routes/zhihu/zhuanlan.ts index ea0595318..101cf06e6 100644 --- a/lib/routes/zhihu/zhuanlan.ts +++ b/lib/routes/zhihu/zhuanlan.ts @@ -1,6 +1,6 @@ import { Route } from '@/types'; import got from '@/utils/got'; -import { header } from './utils'; +import { getSignedHeader, header } from './utils'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; @@ -56,7 +56,13 @@ async function handler(ctx) { url = `https://www.zhihu.com/column/${id}`; } - const infoRes = await got(url); + const signedHeader = await getSignedHeader(url, `https://www.zhihu.com/api/v4/columns/${id}/items`); + const infoRes = await got(url, { + headers: { + ...signedHeader, + Referer: url, + }, + }); const $ = load(infoRes.data); const title = $('.css-zyehvu').text(); const description = $('.css-1bnklpv').text();