From b20848d7116b206ea33007a7dc062e04a0e0e9f7 Mon Sep 17 00:00:00 2001 From: bmy <2271608011@qq.com> Date: Thu, 28 Nov 2024 10:36:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96=E6=80=BB?= =?UTF-8?q?=E9=A1=B5=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- newBackApi/app.js | 16 ++++++++++++++-- newBackApi/router/search.js | 2 +- newBackApi/router/tags.js | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/newBackApi/app.js b/newBackApi/app.js index 6efc7f1..b629861 100644 --- a/newBackApi/app.js +++ b/newBackApi/app.js @@ -6,10 +6,12 @@ import tagsRouter from "./router/tags.js"; import infoRouter from "./router/info.js"; import searchRouter from "./router/search.js"; import homeRouter from "./router/home.js"; - +import http from "http"; const app = express() + + //解决跨域 app.use((req, res, next) => { // 设置是否运行客户端设置 withCredentials @@ -32,7 +34,7 @@ app.use('/v1/api/info', infoRouter); app.use('/v1/api/search', searchRouter); app.use('/v1/api/home', homeRouter); -app.listen(config.port, () => { +http.createServer(app).listen(config.port, "::",() => { console.log(` 爬虫运行在下面网址: @@ -42,5 +44,15 @@ app.listen(config.port, () => { `) }) +// app.listen(config.port, () => { +// console.log(` +// 爬虫运行在下面网址: + +// 1️⃣ 公网 IPV6: http://[${ipv6()}]:${config.port} +// 2️⃣ 局域网 IPV4: http://${ipv4()}:${config.port} + +// `) +// }) + export default app \ No newline at end of file diff --git a/newBackApi/router/search.js b/newBackApi/router/search.js index 9be8f4c..52edbe6 100644 --- a/newBackApi/router/search.js +++ b/newBackApi/router/search.js @@ -44,7 +44,7 @@ router.get('/key', async (req, res) => { let $ = await Util.get(`${Config.baseUrl}/page/${page}?s=${encodeURI(keyword)}&type=post`) let result = { currentPage: page, - totalPage: Number($(".pagenav a").eq(1).text()), + totalPage: Number($(".pagenav .dots+a").text()), message: $(".search-content .badg .focus-color").text(), list: [], } diff --git a/newBackApi/router/tags.js b/newBackApi/router/tags.js index 03f996b..1bb50bd 100644 --- a/newBackApi/router/tags.js +++ b/newBackApi/router/tags.js @@ -50,7 +50,7 @@ router.get('/info', async (req, res) => { let result = { count: $(".content-layout .title-h-left .icon-spot").text().replace(/[^\d]/g, ""), introduce: $(".content-layout .muted-2-color").text(), - totalPage: $(".pagenav a").eq(2).text(), + totalPage: Number($(".pagenav .dots+a").text()), currentPage: page, list: [] }