diff --git a/src/utils.ts b/src/utils.ts index 6f32e9a..d2251be 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -2,7 +2,24 @@ import type { IEventInfo, Player } from "./types"; import * as cheerio from "cheerio"; import { chunk } from 'lodash'; -export const BASE_URL = `https://kaiqiuwang.cc`; +export const BASE_URL = `https://kaiqiuwang.cc`; + +const htmlRequestHeaders = { + "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8", + "accept-language": "zh-CN,zh;q=0.8", + "cache-control": "max-age=0", + "priority": "u=0, i", + "sec-ch-ua": "\"Not(A:Brand\";v=\"8\", \"Chromium\";v=\"144\", \"Brave\";v=\"144\"", + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": "\"Windows\"", + "sec-fetch-dest": "document", + "sec-fetch-mode": "navigate", + "sec-fetch-site": "none", + "sec-fetch-user": "?1", + "sec-gpc": "1", + "upgrade-insecure-requests": "1", + "cookie": "SECKEY_ABVK=oTGgqH4ypGPFVdQ3J9K7PoAOPdZ+8R7CsUzi75gelcg%3D; uchome_sendmail=1" +} /** * @param tagid 俱乐部 ID @@ -17,7 +34,7 @@ export async function listEvent(tagid: string): Promise { */ export async function fetchEventListHTML(tagid: string) { const url = `${BASE_URL}/home/space.php?do=mtag&tagid=${tagid}&view=event`; - const resp = await fetch(url); + const resp = await fetch(url, { headers: htmlRequestHeaders }); return resp.text() ?? ''; } @@ -49,7 +66,7 @@ export function parseEventList(html: string) { */ export async function fetchEventContentHTML(matchId: string) { const url = `${BASE_URL}/home/space.php?do=event&id=${matchId}&view=member&status=2`; - const resp = await fetch(url); + const resp = await fetch(url, { headers: htmlRequestHeaders }); return resp.text() ?? '' }