diff --git a/lib/config.ts b/lib/config.ts index 709efbede..9c9d09fc3 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -284,6 +284,9 @@ export type Config = { ximalaya: { token?: string; }; + xsijishe: { + cookie?: string; + }; xueqiu: { cookies?: string; }; @@ -645,6 +648,9 @@ const calculateValue = () => { ximalaya: { token: envs.XIMALAYA_TOKEN, }, + xsijishe: { + cookie: envs.XSIJISHE_COOKIE, + }, xueqiu: { cookies: envs.XUEQIU_COOKIES, }, diff --git a/lib/routes/xsijishe/forum.ts b/lib/routes/xsijishe/forum.ts index fe332093c..b2731a342 100644 --- a/lib/routes/xsijishe/forum.ts +++ b/lib/routes/xsijishe/forum.ts @@ -3,6 +3,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; +import { config } from '@/config'; const baseUrl = 'https://xsijishe.com'; export const route: Route = { @@ -11,7 +12,12 @@ export const route: Route = { example: '/xsijishe/forum/51', parameters: { fid: '子论坛 id' }, features: { - requireConfig: false, + requireConfig: [ + { + name: 'XSIJISHE_COOKIE', + description: '', + }, + ], requirePuppeteer: false, antiCrawler: false, supportBT: false, @@ -29,7 +35,14 @@ export const route: Route = { async function handler(ctx) { const fid = ctx.req.param('fid'); const url = `${baseUrl}/forum-${fid}-1.html`; - const resp = await got(url); + const headers = { + 'Accept-Encoding': 'gzip, deflate, br', + 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8', + Cookie: config.xsijishe.cookie, + }; + const resp = await got(url, { + headers, + }); const $ = load(resp.data); const forumCategory = $('.nex_bkinterls_top .nex_bkinterls_ls a').text(); let items = $('[id^="normalthread"]') @@ -51,7 +64,9 @@ async function handler(ctx) { items = await Promise.all( items.map((item) => cache.tryGet(item.link, async () => { - const resp = await got(item.link); + const resp = await got(item.link, { + headers, + }); const $ = load(resp.data); const firstViewBox = $('.t_f').first(); diff --git a/lib/routes/xsijishe/rank.ts b/lib/routes/xsijishe/rank.ts index fd95af2be..857aa9ff6 100644 --- a/lib/routes/xsijishe/rank.ts +++ b/lib/routes/xsijishe/rank.ts @@ -53,7 +53,9 @@ async function handler(ctx) { items = await Promise.all( items.map((item) => cache.tryGet(item.link, async () => { - const resp = await got(item.link); + const resp = await got(item.link, { + headers, + }); const $ = load(resp.data); const firstViewBox = $('.t_f').first();