mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-04 11:07:54 +08:00
35 lines
917 B
JavaScript
35 lines
917 B
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
|
|
module.exports = async (ctx) => {
|
|
const id = ctx.params.id || 92685;
|
|
|
|
const link = `https://www.luogu.org/discuss/show/${id}`;
|
|
const response = await got.get(link);
|
|
const $ = cheerio.load(response.data);
|
|
const title = $('#app-body-new div h1').text();
|
|
|
|
const out = $('div.am-comment-main > div > p')
|
|
.slice(0, 10)
|
|
.map(function() {
|
|
const info = {
|
|
title:
|
|
$(this)
|
|
.find('strong')
|
|
.text() || $(this).text(),
|
|
description: $(this).html(),
|
|
link: $(this)
|
|
.find('a')
|
|
.attr('href'),
|
|
};
|
|
return info;
|
|
})
|
|
.get();
|
|
|
|
ctx.state.data = {
|
|
title: title,
|
|
link: link,
|
|
item: out,
|
|
};
|
|
};
|