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: [] }