Files
RSSHub/lib/v2/jike/topicText.js
Rongrong 63ccc9499b fix(route/jike): image URL; outdated usage (#9693)
* fix(route/jike): image URL; outdated usage

Signed-off-by: Rongrong <i@rong.moe>

* refactor: migrate to v2

* fix: unescaped .

* feat(route/jike): new radar rule

Signed-off-by: Rongrong <i@rong.moe>
2022-05-05 20:28:04 +08:00

37 lines
1.1 KiB
JavaScript

const got = require('@/utils/got');
const dayjs = require('dayjs');
const common = require('./common');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const id = ctx.params.id;
const response = await got(`https://m.okjike.com/topics/${id}`);
const html = response.data;
const $ = cheerio.load(html);
const raw = $('[type = "application/json"]').html();
const data = JSON.parse(raw).props.pageProps;
if (common.emptyResponseCheck(ctx, data)) {
return;
}
const title = data.topic.content;
ctx.state.data = {
title: `${title} - 即刻`,
link: `https://m.okjike.com/topics/${id}`,
description: `${title} - 即刻`,
item: data.posts.map((item) => {
const date = dayjs(item.createdAt);
return {
title: `${title} ${date.format('MM月DD日')}`,
description: item.content.replace(/\n/g, '<br>'),
pubDate: date.toDate(),
link: `https://m.okjike.com/originalPosts/${item.id}`,
};
}),
};
};