42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
import express from "express";
|
|
import Util from '../utils/index.js'
|
|
import Config from '../config/config.js'
|
|
|
|
const router = express.Router();
|
|
|
|
// 进入详情的接口
|
|
// http://192.168.31.101:3030/v1/api/info/list?id=6808
|
|
router.get('/list', async (req, res) => {
|
|
let { id } = req.query
|
|
let $ = await Util.get(`${Config.baseUrl}/${id}.html`)
|
|
let result = {
|
|
title: $(".article .article-header .article-title a").text(),
|
|
src_list: [],
|
|
recommend: [],
|
|
}
|
|
|
|
$(".article-content .wp-posts-content p img").map(function(i, el) {
|
|
result.src_list.push($(el).attr("data-src"))
|
|
})
|
|
|
|
$(".swiper-container .swiper-slide a").each(function(i, el) {
|
|
result.recommend.push({
|
|
id: Util.split($(this).attr("href")).replace(/[^\d]/g, ""),
|
|
thumbnail: $(this).find("img").attr("data-src"),
|
|
title: $(this).find(".text-ellipsis").text(),
|
|
time: $(this).find(".px12 item").eq(0).text(),
|
|
view: $(this).find(".px12 item").eq(1).text(),
|
|
})
|
|
})
|
|
|
|
res.json({
|
|
status: 200,
|
|
copyright: `bmy ${new Date()}`,
|
|
data: result
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
export default router |