mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 06:30:40 +08:00
feat(route): freewechat (#11419)
This commit is contained in:
@@ -3884,32 +3884,32 @@ column 为 third 时可选的 category:
|
|||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
### 公众号 (优读来源)
|
### 公众号(优读来源)
|
||||||
|
|
||||||
<Route author="kt286" example="/wechat/uread/shensing" path="/wechat/uread/:userid" :paramsDesc="['公众号的微信号, 可在 微信-公众号-更多资料 中找到。并不是所有的都支持,能不能用随缘']"/>
|
<Route author="kt286" example="/wechat/uread/shensing" path="/wechat/uread/:userid" :paramsDesc="['公众号的微信号, 可在 微信-公众号-更多资料 中找到。并不是所有的都支持,能不能用随缘']"/>
|
||||||
|
|
||||||
### 公众号 (二十次幂来源)
|
### 公众号(二十次幂来源)
|
||||||
|
|
||||||
<Route author="sanmmm" example="/wechat/ershicimi/813oxJOl" path="/wechat/ershicimi/:id" :paramsDesc="['公众号id, 打开公众号页, 在 URL 中找到 id']" anticrawler="1"/>
|
<Route author="sanmmm" example="/wechat/ershicimi/813oxJOl" path="/wechat/ershicimi/:id" :paramsDesc="['公众号id, 打开公众号页, 在 URL 中找到 id']" anticrawler="1"/>
|
||||||
|
|
||||||
### 公众号 (微阅读来源)
|
### 公众号(微阅读来源)
|
||||||
|
|
||||||
<Route author="Rongronggg9" example="/wechat/data258/gh_cbbad4c1d33c" path="/data258/:id?" :paramsDesc="['公众号 id 或分类 id,可在公众号页或分类页 URL 中找到;若略去,则抓取首页']" anticrawler="1" radar="1" rssbud="1" selfhost="1">
|
<Route author="Rongronggg9" example="/wechat/data258/gh_cbbad4c1d33c" path="/data258/:id?" :paramsDesc="['公众号 id 或分类 id,可在公众号页或分类页 URL 中找到;若略去,则抓取首页']" anticrawler="1" radar="1" rssbud="1" selfhost="1">
|
||||||
|
|
||||||
::: warning 注意
|
::: warning 注意
|
||||||
|
|
||||||
由于使用了一些针对反爬的缓解措施,本路由响应较慢。默认只抓取前 5 条,可通过 `?limit=` 改变(不推荐,容易被反爬)。\
|
由于使用了一些针对反爬的缓解措施,本路由响应较慢。默认只抓取前 5 条,可通过 `?limit=` 改变(不推荐,容易被反爬)。\
|
||||||
该网站使用 IP 甄别访客,且应用严格的每日阅读量限额 (约 15 次),请自建并确保正确配置缓存;如使用内存缓存而非 Redis 缓存,请增大缓存容量。该限额足够订阅至少 3 个公众号 (假设公众号每日仅更新一次);首页 / 分类页更新相当频繁,不推荐订阅。
|
该网站使用 IP 甄别访客,且应用严格的每日阅读量限额(约 15 次),请自建并确保正确配置缓存;如使用内存缓存而非 Redis 缓存,请增大缓存容量。该限额足够订阅至少 3 个公众号 (假设公众号每日仅更新一次);首页 / 分类页更新相当频繁,不推荐订阅。
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
### 公众号 (wxnmh.com 来源)
|
### 公众号(wxnmh.com 来源)
|
||||||
|
|
||||||
<Route author="laampui" example="/wechat/wxnmh/51798" path="/wechat/wxnmh/:id" :paramsDesc="['公众号 id, 打开 wxnmh.com, 在 URL 中找到 id']" anticrawler="1"/>
|
<Route author="laampui" example="/wechat/wxnmh/51798" path="/wechat/wxnmh/:id" :paramsDesc="['公众号 id, 打开 wxnmh.com, 在 URL 中找到 id']" anticrawler="1"/>
|
||||||
|
|
||||||
### 公众号 (wechat-feeds 来源)
|
### 公众号(wechat-feeds 来源)
|
||||||
|
|
||||||
::: warning 注意
|
::: warning 注意
|
||||||
|
|
||||||
@@ -3919,14 +3919,18 @@ wechat-feeds 来源[已停止更新](https://github.com/hellodword/wechat-feeds/
|
|||||||
|
|
||||||
<Route author="tylinux" example="/wechat/feeds/MzIwMzAwMzQxNw==" path="/wechat/feeds/:id" :paramsDesc="['公众号 id, 打开 `https://wechat.privacyhide.com/`, 在选定公众号的订阅 URL 中找到 id, 不包含最后的 .xml']"/>
|
<Route author="tylinux" example="/wechat/feeds/MzIwMzAwMzQxNw==" path="/wechat/feeds/:id" :paramsDesc="['公众号 id, 打开 `https://wechat.privacyhide.com/`, 在选定公众号的订阅 URL 中找到 id, 不包含最后的 .xml']"/>
|
||||||
|
|
||||||
### 公众号 (feeddd 来源)
|
### 公众号(feeddd 来源))
|
||||||
|
|
||||||
<Route author="TonyRL Rongronggg9" example="/wechat/feeddd/6131e1441269c358aa0e2141" path="/wechat/feeddd/:id" :paramsDesc="['公众号 id, 打开 `https://feeddd.org/feeds` 或 `https://cdn.jsdelivr.net/gh/feeddd/feeds/feeds_all_rss.txt`, 在 URL 中找到 id; 注意不是公众号页的 id, 而是订阅的 id']"/>
|
<Route author="TonyRL Rongronggg9" example="/wechat/feeddd/6131e1441269c358aa0e2141" path="/wechat/feeddd/:id" :paramsDesc="['公众号 id, 打开 `https://feeddd.org/feeds` 或 `https://cdn.jsdelivr.net/gh/feeddd/feeds/feeds_all_rss.txt`, 在 URL 中找到 id; 注意不是公众号页的 id, 而是订阅的 id']"/>
|
||||||
|
|
||||||
### 公众号 (公众号 360 来源)
|
### 公众号(公众号 360 来源)
|
||||||
|
|
||||||
见 [#公众号 360](#gong-zhong-hao-360)
|
见 [#公众号 360](#gong-zhong-hao-360)
|
||||||
|
|
||||||
|
### 公众号(自由微信来源)
|
||||||
|
|
||||||
|
见 [#自由微信](#zi-you-wei-xin)
|
||||||
|
|
||||||
### 公众号栏目 (非推送 & 历史消息)
|
### 公众号栏目 (非推送 & 历史消息)
|
||||||
|
|
||||||
<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">
|
||||||
@@ -4579,3 +4583,9 @@ QueryString:
|
|||||||
| | zh-hk | zh-tw |
|
| | zh-hk | zh-tw |
|
||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
## 自由微信
|
||||||
|
|
||||||
|
### 公众号
|
||||||
|
|
||||||
|
<Route author="TonyRL" example="/freewechat/profile/MzI5NTUxNzk3OA==" path="/freewechat/profile/:id" :paramsDesc="['公众号 ID,可在URL中找到']" radar="1" rssbud="1" anticrawler="1"/>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
* lib/v2/sdu/cs
|
* lib/v2/sdu/cs
|
||||||
* lib/v2/nua/utils
|
* lib/v2/nua/utils
|
||||||
* lib/v2/hrbeu
|
* lib/v2/hrbeu
|
||||||
|
* lib/v2/freewechat
|
||||||
*
|
*
|
||||||
* If your new route is not in the above folders, please add it to the list.
|
* If your new route is not in the above folders, please add it to the list.
|
||||||
*
|
*
|
||||||
|
|||||||
3
lib/v2/freewechat/maintainer.js
Normal file
3
lib/v2/freewechat/maintainer.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
'/profile/:id': ['TonyRL'],
|
||||||
|
};
|
||||||
61
lib/v2/freewechat/profile.js
Normal file
61
lib/v2/freewechat/profile.js
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
const timezone = require('@/utils/timezone');
|
||||||
|
const { fixArticleContent } = require('@/utils/wechat-mp');
|
||||||
|
const baseUrl = 'https://freewechat.com';
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const { id } = ctx.params;
|
||||||
|
const url = `${baseUrl}/profile/${id}`;
|
||||||
|
const { data: response } = await got(url);
|
||||||
|
const $ = cheerio.load(response);
|
||||||
|
const author = $('h2').text().trim();
|
||||||
|
|
||||||
|
const list = $('.main')
|
||||||
|
.toArray()
|
||||||
|
.slice(0, -1) // last item is a template
|
||||||
|
.map((item) => {
|
||||||
|
item = $(item);
|
||||||
|
return {
|
||||||
|
title: item.find('a').text(),
|
||||||
|
author,
|
||||||
|
link: `${baseUrl}${item.find('a').attr('href')}`,
|
||||||
|
description: item.find('.preview').text(),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const items = await Promise.all(
|
||||||
|
list.map((item) =>
|
||||||
|
ctx.cache.tryGet(item.link, async () => {
|
||||||
|
const response = await got(item.link, {
|
||||||
|
headers: {
|
||||||
|
Referer: url,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
|
||||||
|
$('.js_img_placeholder').remove();
|
||||||
|
$('amp-img').each((_, e) => {
|
||||||
|
e = $(e);
|
||||||
|
e.replaceWith(`<img src="${new URL(e.attr('src'), response.url).href}" width="${e.attr('width')}" height="${e.attr('height')}" decoding="async">`);
|
||||||
|
});
|
||||||
|
$('amp-video').each((_, e) => {
|
||||||
|
e = $(e);
|
||||||
|
e.replaceWith(`<video width="${e.attr('width')}" height="${e.attr('height')}" controls poster="${e.attr('poster')}">${e.html()}</video>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
item.description = fixArticleContent($('#js_content'));
|
||||||
|
item.pubDate = timezone(parseDate($('#publish_time').text()), +8);
|
||||||
|
return item;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: $('head title').text(),
|
||||||
|
link: url,
|
||||||
|
image: 'https://freewechat.com/favicon.ico',
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
};
|
||||||
13
lib/v2/freewechat/radar.js
Normal file
13
lib/v2/freewechat/radar.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
module.exports = {
|
||||||
|
'freewechat.com': {
|
||||||
|
_name: '自由微信',
|
||||||
|
'.': [
|
||||||
|
{
|
||||||
|
title: '公众号',
|
||||||
|
docs: 'https://docs.rsshub.app/new-media.html#zi-you-wei-xin',
|
||||||
|
source: ['/profile/:id'],
|
||||||
|
target: '/freewechat/profile/:id',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
3
lib/v2/freewechat/router.js
Normal file
3
lib/v2/freewechat/router.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = (router) => {
|
||||||
|
router.get('/profile/:id', require('./profile'));
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user