This commit is contained in:
40
router/hot.js
Normal file
40
router/hot.js
Normal file
@@ -0,0 +1,40 @@
|
||||
import express from "express";
|
||||
import Util from '../utils/index.js'
|
||||
import Config from '../config/config.js'
|
||||
import utils from "../utils/index.js";
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
// 进入详情的接口
|
||||
// http://192.168.31.101:9940/v1/api/hot/list&page=1
|
||||
router.get('/list', async (req, res) => {
|
||||
let { page } = req.query
|
||||
page = page || 1
|
||||
|
||||
let $ = await Util.get(`${Config.baseUrl}/other/page/${page}`)
|
||||
|
||||
let result = {
|
||||
currentPage: page,
|
||||
totalPage: utils.maxPage(".pagenav a", $),
|
||||
message: $(".search-content .badg .focus-color").text(),
|
||||
list: [],
|
||||
}
|
||||
|
||||
$(".posts-row .posts-item").each(function() {
|
||||
result.list.push({
|
||||
id: Util.split($(this).find(".item-thumbnail a").attr("href")).replace(/[^\d]/g, ""),
|
||||
thumbnail: $(this).find(".item-thumbnail a img").attr("data-src"),
|
||||
title: $(this).find(".item-heading a").text(),
|
||||
time: $(this).find(".item-meta .icon-circle").text(),
|
||||
view: $(this).find(".item-meta .meta-right .meta-view").text()
|
||||
})
|
||||
})
|
||||
|
||||
res.json({
|
||||
status: 200,
|
||||
copyright: `bmy ${new Date()}`,
|
||||
data: result
|
||||
})
|
||||
})
|
||||
|
||||
export default router
|
||||
Reference in New Issue
Block a user