mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 15:21:59 +08:00
feat: add 企鹅号全文输出 (#3072)
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
const got = require('@/utils/got');
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const date = require('@/utils/date');
|
||||||
|
const iconv = require('iconv-lite');
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
const mid = ctx.params.mid;
|
const mid = ctx.params.mid;
|
||||||
@@ -12,24 +15,39 @@ module.exports = async (ctx) => {
|
|||||||
const reponse = response.data;
|
const reponse = response.data;
|
||||||
const title = reponse.mediainfo.name;
|
const title = reponse.mediainfo.name;
|
||||||
const description = reponse.mediainfo.intro;
|
const description = reponse.mediainfo.intro;
|
||||||
const list = reponse.data;
|
const list = reponse.data.splice(0, 10);
|
||||||
|
|
||||||
const items = list.map((item) => {
|
const items = await Promise.all(
|
||||||
const title = item.title;
|
list.map(async (item) => {
|
||||||
const date = Date(item.timestamp);
|
const title = item.title;
|
||||||
const itemUrl = item.vurl;
|
const unixTimestamp = new Date(item.timestamp * 1000);
|
||||||
const author = item.source;
|
const pubDate = date(unixTimestamp.toLocaleString(), 8);
|
||||||
const description = item.abstract;
|
const itemUrl = item.vurl;
|
||||||
|
const author = item.source;
|
||||||
|
const abstract = item.abstract;
|
||||||
|
|
||||||
|
const response = await ctx.cache.tryGet(
|
||||||
|
itemUrl,
|
||||||
|
async () =>
|
||||||
|
(await got.get(itemUrl, {
|
||||||
|
responseType: 'buffer',
|
||||||
|
})).data
|
||||||
|
);
|
||||||
|
const html = iconv.decode(response, 'gbk');
|
||||||
|
const $ = cheerio.load(html, { decodeEntities: false });
|
||||||
|
const article = $('div.content-article');
|
||||||
|
|
||||||
|
const single = {
|
||||||
|
title,
|
||||||
|
description: article.html() || abstract,
|
||||||
|
link: itemUrl,
|
||||||
|
author,
|
||||||
|
pubDate,
|
||||||
|
};
|
||||||
|
return Promise.resolve(single);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
const single = {
|
|
||||||
title,
|
|
||||||
description,
|
|
||||||
link: itemUrl,
|
|
||||||
author,
|
|
||||||
pubDate: date,
|
|
||||||
};
|
|
||||||
return single;
|
|
||||||
});
|
|
||||||
ctx.state.data = {
|
ctx.state.data = {
|
||||||
title: title,
|
title: title,
|
||||||
description: description,
|
description: description,
|
||||||
|
|||||||
Reference in New Issue
Block a user