From 4286c6c0aa0b86aa71e1cd6ab9aed6bd671579c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=8C=8C?= Date: Wed, 30 Oct 2024 00:00:11 +0800 Subject: [PATCH] =?UTF-8?q?fetch=20=E6=98=AF=E7=A5=96=E5=AE=97=E4=B9=8B?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/profile/ProfileStat.js | 11 ++++------- package.json | 8 +++----- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/apps/profile/ProfileStat.js b/apps/profile/ProfileStat.js index 9722a2dd..3e80b946 100644 --- a/apps/profile/ProfileStat.js +++ b/apps/profile/ProfileStat.js @@ -2,8 +2,8 @@ import { Common } from '#miao' import { MysApi, Player, Character } from '#miao.models' import moment from 'moment' import lodash from 'lodash' -import axios from 'axios' import cheerio from 'cheerio' +import fetch from 'node-fetch' const ProfileStat = { async stat (e) { @@ -120,8 +120,7 @@ const ProfileStat = { const request_url = 'https://homdgcat.wiki/gi/CH/maze.js' let resData = false try { - const response = await axios.get(request_url, {timeout: 5000}) - resData = response.data + resData = await (await fetch(request_url)).text() } catch (error) { logger.error('请求失败:', error) return false // 直接返回以停止后续逻辑 @@ -180,8 +179,7 @@ const ProfileStat = { const request_url = 'https://wiki.biligame.com/ys/%E5%B9%BB%E6%83%B3%E7%9C%9F%E5%A2%83%E5%89%A7%E8%AF%97' try { // 发送 GET 请求 - const response = await axios.get(request_url, {timeout: 5000}); - const html = response.data; + const html = await (await fetch(request_url)).text() // 加载 HTML const $ = cheerio.load(html); @@ -209,8 +207,7 @@ const ProfileStat = { const request_url = `https://wiki.biligame.com/${links[mazeId]}` // 发送 GET 请求 - const response = await axios.get(request_url, {timeout: 5000}); - const html = response.data; + const html = await (await fetch(request_url)).text() // 加载 HTML const $ = cheerio.load(html); diff --git a/package.json b/package.json index 229719e0..1ee88e34 100644 --- a/package.json +++ b/package.json @@ -4,14 +4,12 @@ "author": "Yoimiya-Kokomi", "description": "miao-plugin", "type": "module", - "scripts": { - }, + "scripts": {}, "dependencies": { - "image-size": "^1.0.2", - "axios": "^1.7.7" + "image-size": "^1.1.1" }, "devDependencies": { - "cheerio": "1.0.0-rc.12", + "cheerio": "1.0.0", "request": "^2.88.2" }, "imports": {