mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +08:00
feat(route): 微信公众号新增 wechat-feeds 来源 (#7419)
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
@@ -74,7 +74,7 @@ pageClass: routes
|
|||||||
|
|
||||||
### Home
|
### Home
|
||||||
|
|
||||||
<RouteEn author="nczitzk" example="/elitebabes" path="/elitebabes/:category?" :paramsDesc="['Category, see below, Home by default']">
|
<RouteEn author="nczitzk" example="/elitebabes" path="/elitebabes/:category?" :paramsDesc="['Category, see below, Home by default']"/>
|
||||||
|
|
||||||
| Home | Hot | Popular | Recent |
|
| Home | Hot | Popular | Recent |
|
||||||
| ---- | --- | ------- | ------ |
|
| ---- | --- | ------- | ------ |
|
||||||
@@ -84,7 +84,7 @@ pageClass: routes
|
|||||||
|
|
||||||
### Videos
|
### Videos
|
||||||
|
|
||||||
<RouteEn author="nczitzk" example="/elitebabes/videos" path="/elitebabes/videos/:sort?" :paramsDesc="['Sort, see below, Popular by default']">
|
<RouteEn author="nczitzk" example="/elitebabes/videos" path="/elitebabes/videos/:sort?" :paramsDesc="['Sort, see below, Popular by default']" />
|
||||||
|
|
||||||
| Popular | Recent |
|
| Popular | Recent |
|
||||||
| ------- | ------ |
|
| ------- | ------ |
|
||||||
|
|||||||
@@ -2066,6 +2066,10 @@ column 为 third 时可选的 category:
|
|||||||
|
|
||||||
<Route author="laampui" example="/wechat/wxnmh/51798" path="/wechat/wxnmh/:id" :paramsDesc="['公众号 id, 打开 wxnmh.com, 在 URL 中找到 id']"/>
|
<Route author="laampui" example="/wechat/wxnmh/51798" path="/wechat/wxnmh/:id" :paramsDesc="['公众号 id, 打开 wxnmh.com, 在 URL 中找到 id']"/>
|
||||||
|
|
||||||
|
### 公众号 (wechat-feeds 来源)
|
||||||
|
|
||||||
|
<Route author="tylinux" example="/wechat/feeds/MzIwMzAwMzQxNw==" path="/wechat/feeds/:id" :paramsDesc="['公众号 id, 打开 `https://wechat.privacyhide.com/`, 在选定公众号的订阅 URL 中找到 id, 不包含最后的 .xml']"/>
|
||||||
|
|
||||||
### 公众号栏目 (非推送 & 历史消息)
|
### 公众号栏目 (非推送 & 历史消息)
|
||||||
|
|
||||||
<Route author="MisteryMonster" example="/wechat/mp/homepage/MzA3MDM3NjE5NQ==/16" path="/wechat/mp/homepage/:biz/:hid/:cid?" :paramsDesc="['公众号id', '分页id', '页内栏目']" radar="1" rssbud="1" anticrawler="1">
|
<Route author="MisteryMonster" example="/wechat/mp/homepage/MzA3MDM3NjE5NQ==/16" path="/wechat/mp/homepage/:biz/:hid/:cid?" :paramsDesc="['公众号id', '分页id', '页内栏目']" radar="1" rssbud="1" anticrawler="1">
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ pageClass: routes
|
|||||||
|
|
||||||
## Dilbert Comic Strip
|
## Dilbert Comic Strip
|
||||||
|
|
||||||
<Route name="Daily Strip" author="Maecenas" example="/dilbert/strip" path="/dilbert/strip">
|
<Route name="Daily Strip" author="Maecenas" example="/dilbert/strip" path="/dilbert/strip" />
|
||||||
|
|
||||||
通过提取漫画,提供比官方源更佳的阅读体验。
|
通过提取漫画,提供比官方源更佳的阅读体验。
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ pageClass: routes
|
|||||||
|
|
||||||
### Home
|
### Home
|
||||||
|
|
||||||
<Route author="nczitzk" example="/elitebabes" path="/elitebabes/:category?" :paramsDesc="['分类,见下表,默认为 Home']">
|
<Route author="nczitzk" example="/elitebabes" path="/elitebabes/:category?" :paramsDesc="['分类,见下表,默认为 Home']" />
|
||||||
|
|
||||||
| Home | Hot | Popular | Recent |
|
| Home | Hot | Popular | Recent |
|
||||||
| ---- | --- | ------- | ------ |
|
| ---- | --- | ------- | ------ |
|
||||||
@@ -108,7 +108,7 @@ pageClass: routes
|
|||||||
|
|
||||||
### Videos
|
### Videos
|
||||||
|
|
||||||
<Route author="nczitzk" example="/elitebabes/videos" path="/elitebabes/videos/:sort?" :paramsDesc="['排序,见下表,默认为 Popular']">
|
<Route author="nczitzk" example="/elitebabes/videos" path="/elitebabes/videos/:sort?" :paramsDesc="['排序,见下表,默认为 Popular']"/>
|
||||||
|
|
||||||
| Popular | Recent |
|
| Popular | Recent |
|
||||||
| ------- | ------ |
|
| ------- | ------ |
|
||||||
|
|||||||
@@ -537,6 +537,7 @@ router.get('/wechat/wjdn/:id', require('./routes/tencent/wechat/wjdn'));
|
|||||||
router.get('/wechat/wxnmh/:id', require('./routes/tencent/wechat/wxnmh'));
|
router.get('/wechat/wxnmh/:id', require('./routes/tencent/wechat/wxnmh'));
|
||||||
router.get('/wechat/mp/homepage/:biz/:hid/:cid?', require('./routes/tencent/wechat/mp'));
|
router.get('/wechat/mp/homepage/:biz/:hid/:cid?', require('./routes/tencent/wechat/mp'));
|
||||||
router.get('/wechat/mp/msgalbum/:biz/:aid', require('./routes/tencent/wechat/msgalbum'));
|
router.get('/wechat/mp/msgalbum/:biz/:aid', require('./routes/tencent/wechat/msgalbum'));
|
||||||
|
router.get('/wechat/feeds/:id', require('./routes/tencent/wechat/feeds'));
|
||||||
|
|
||||||
// All the Flight Deals
|
// All the Flight Deals
|
||||||
router.get('/atfd/:locations/:nearby?', require('./routes/atfd/index'));
|
router.get('/atfd/:locations/:nearby?', require('./routes/atfd/index'));
|
||||||
|
|||||||
47
lib/routes/tencent/wechat/feeds.js
Normal file
47
lib/routes/tencent/wechat/feeds.js
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
const parser = require('@/utils/rss-parser');
|
||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const { id } = ctx.params;
|
||||||
|
const link = `https://github.com/hellodword/wechat-feeds/raw/feeds/${id}.xml`;
|
||||||
|
const feed = await parser.parseURL(link);
|
||||||
|
|
||||||
|
const items = await Promise.all(
|
||||||
|
feed.items.map(async (item) => {
|
||||||
|
const cache = await ctx.cache.get(item.link);
|
||||||
|
if (cache) {
|
||||||
|
return Promise.resolve(JSON.parse(cache));
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await got.get(item.link);
|
||||||
|
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
const post = $('#js_content');
|
||||||
|
|
||||||
|
post.find('img').each((_, img) => {
|
||||||
|
const dataSrc = $(img).attr('data-src');
|
||||||
|
if (dataSrc) {
|
||||||
|
$(img).attr('src', dataSrc);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const single = {
|
||||||
|
title: item.title,
|
||||||
|
description: post.html(),
|
||||||
|
pubDate: new Date(item.pubDate),
|
||||||
|
link: item.link,
|
||||||
|
};
|
||||||
|
|
||||||
|
ctx.cache.set(item.link, JSON.stringify(single));
|
||||||
|
return Promise.resolve(single);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `${feed.title}`,
|
||||||
|
link,
|
||||||
|
description: feed.description,
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user