mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-01 17:48:15 +08:00
* fix(utils): 支持微信公众号单图片文章抓取 * fix(utils): 支持输出微信公众号转载文章阅读原文链接 * fix(utils): 修复抓取微信已删除文章时遇到的报错 * refactor: migrate to v2 Co-authored-by: blankyu(于海洋) <blankyu@tencent.com>
52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
|
|
module.exports = async (ctx) => {
|
|
const userid = ctx.params.userid;
|
|
const url = `http://119.29.146.143:8080/reading/subscription/account/recent?uid=${userid}`;
|
|
const response = await got({
|
|
method: 'get',
|
|
url,
|
|
});
|
|
const data = response.data;
|
|
|
|
const ProcessFeed = (data) => {
|
|
const $ = cheerio.load(data);
|
|
return $('.rich_media_content').html();
|
|
};
|
|
|
|
const items = await Promise.all(
|
|
data.data.map(async (item) => {
|
|
const link = item.url;
|
|
|
|
const cache = await ctx.cache.get(link);
|
|
if (cache) {
|
|
return Promise.resolve(JSON.parse(cache));
|
|
}
|
|
|
|
const response = await got({
|
|
method: 'get',
|
|
url: link,
|
|
});
|
|
|
|
const description = ProcessFeed(response.data);
|
|
|
|
const single = {
|
|
title: item.title,
|
|
description,
|
|
link,
|
|
author: item.official_account,
|
|
pubDate: item.publish_time,
|
|
};
|
|
ctx.cache.set(link, JSON.stringify(single));
|
|
return Promise.resolve(single);
|
|
})
|
|
);
|
|
|
|
ctx.state.data = {
|
|
title: `优读 - ${userid}`,
|
|
link: 'https://uread.ai/',
|
|
item: items,
|
|
};
|
|
};
|