From 2a7f668a0dafb79fcc020b760bb7c83aee6b46a6 Mon Sep 17 00:00:00 2001 From: Unknow <542002829@qq.com> Date: Fri, 20 Mar 2026 18:13:14 +0800 Subject: [PATCH] Fix: Request failed with status code 403 --- lib/fetcher.js | 19 +++++++++++++++---- package.json | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/fetcher.js b/lib/fetcher.js index 5a024cb..fe89ad7 100644 --- a/lib/fetcher.js +++ b/lib/fetcher.js @@ -6,17 +6,28 @@ const BASE_URL = 'https://javdb.com'; const HEADERS = { 'User-Agent': - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) ' + + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) ' + 'AppleWebKit/537.36 (KHTML, like Gecko) ' + - 'Chrome/124.0.0.0 Safari/537.36', + 'Chrome/123.0.0.0 Safari/537.36', + 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8', 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8', - Cookie: 'locale=zh', // 强制返回中文页面 + 'Accept-Encoding': 'gzip, deflate, br', + 'Connection': 'keep-alive', + 'Upgrade-Insecure-Requests': '1', + 'Sec-Fetch-Dest': 'document', + 'Sec-Fetch-Mode': 'navigate', + 'Sec-Fetch-Site': 'none', + 'Sec-Fetch-User': '?1', + 'Cache-Control': 'max-age=0', + Cookie: 'locale=zh; over18=1', // over18=1 跳过成人内容确认页 }; async function fetchHtml(url) { const res = await axios.get(url, { headers: HEADERS, - timeout: 10000, + timeout: 15000, + maxRedirects: 5, + decompress: true, }); return res.data; } diff --git a/package.json b/package.json index 99db1f5..e1ccc6f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "javinfo", - "version": "1.0.0", + "version": "1.0.1", "description": "AV番号命令行查询工具", "main": "./index.js", "type": "module",