mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 22:19:40 +08:00
40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
|
|
module.exports = async (ctx) => {
|
|
const postid = ctx.params.postid;
|
|
const pageUrl = `https://www.v2ex.com/t/${postid}`;
|
|
|
|
const response = await got({
|
|
method: 'get',
|
|
url: pageUrl,
|
|
});
|
|
|
|
const $ = cheerio.load(response.data);
|
|
const list = $('[id^="r_"]').get();
|
|
|
|
ctx.state.data = {
|
|
title: `V2EX-${$('.header h1').text()}`,
|
|
link: pageUrl,
|
|
description: $('.topic_content').text(),
|
|
item: list
|
|
.map((item) => {
|
|
const post = $(item);
|
|
const reply_content = post.find('.reply_content').first();
|
|
const no = post.find('.no').first();
|
|
|
|
return {
|
|
title: `#${no.text()} ${reply_content.text()}`,
|
|
description: reply_content.html(),
|
|
guid: post.attr('id'),
|
|
link: `${pageUrl}#${post.attr('id')}`,
|
|
author: post
|
|
.find('.dark')
|
|
.first()
|
|
.text(),
|
|
};
|
|
})
|
|
.reverse(),
|
|
};
|
|
};
|