fix(route): XSIJISHE need login (#15984)

* 1. 修复sehuatang 403

* 修复sehuatang主页 403

* 过滤不必要的请求

* 修复XSIJISHE需要登录

* 修复XSIJISHE rank需要登录

* This does not require cookie.url
This commit is contained in:
hywell 2024-06-25 21:17:31 +08:00 committed by GitHub
parent a213bf7981
commit e94969b9b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 4 deletions

View File

@ -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,
},

View File

@ -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();

View File

@ -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();