Skip to content

Commit

Permalink
Merge pull request #629 from DIYgod/master
Browse files Browse the repository at this point in the history
[pull] master from diygod:master
  • Loading branch information
pull[bot] authored Dec 9, 2022
2 parents 19c4525 + e1c5e41 commit 87413fa
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 54 deletions.
26 changes: 18 additions & 8 deletions docs/new-media.md
Original file line number Diff line number Diff line change
Expand Up @@ -3884,32 +3884,32 @@ column 为 third 时可选的 category:

</Route>

### 公众号 (优读来源)
### 公众号优读来源

<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="Rongronggg9" example="/wechat/data258/gh_cbbad4c1d33c" path="/data258/:id?" :paramsDesc="['公众号 id 或分类 id,可在公众号页或分类页 URL 中找到;若略去,则抓取首页']" anticrawler="1" radar="1" rssbud="1" selfhost="1">

::: warning 注意

由于使用了一些针对反爬的缓解措施,本路由响应较慢。默认只抓取前 5 条,可通过 `?limit=` 改变(不推荐,容易被反爬)。\
该网站使用 IP 甄别访客,且应用严格的每日阅读量限额 (约 15 次),请自建并确保正确配置缓存;如使用内存缓存而非 Redis 缓存,请增大缓存容量。该限额足够订阅至少 3 个公众号 (假设公众号每日仅更新一次);首页 / 分类页更新相当频繁,不推荐订阅。
该网站使用 IP 甄别访客,且应用严格的每日阅读量限额约 15 次,请自建并确保正确配置缓存;如使用内存缓存而非 Redis 缓存,请增大缓存容量。该限额足够订阅至少 3 个公众号 (假设公众号每日仅更新一次);首页 / 分类页更新相当频繁,不推荐订阅。

:::

</Route>

### 公众号 (wxnmh.com 来源)
### 公众号wxnmh.com 来源

<Route author="laampui" example="/wechat/wxnmh/51798" path="/wechat/wxnmh/:id" :paramsDesc="['公众号 id, 打开 wxnmh.com, 在 URL 中找到 id']" anticrawler="1"/>

### 公众号 (wechat-feeds 来源)
### 公众号wechat-feeds 来源

::: warning 注意

Expand All @@ -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']"/>

### 公众号 (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']"/>

### 公众号 (公众号 360 来源)
### 公众号公众号 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">
Expand Down Expand Up @@ -4579,3 +4583,9 @@ QueryString:
| | zh-hk | zh-tw |

</Route>

## 自由微信

### 公众号

<Route author="TonyRL" example="/freewechat/profile/MzI5NTUxNzk3OA==" path="/freewechat/profile/:id" :paramsDesc="['公众号 ID,可在URL中找到']" radar="1" rssbud="1" anticrawler="1"/>
10 changes: 5 additions & 5 deletions docs/university.md
Original file line number Diff line number Diff line change
Expand Up @@ -2352,15 +2352,15 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS

### 官网信息

<Route author="simonsmh" example="/shmtu/www/events" path="/shmtu/www/:type" :paramsDesc="['类型名称']"/>
<Route author="imbytecat simonsmh" example="/shmtu/www/events" path="/shmtu/www/:type" :paramsDesc="['类型名称']"/>

| 学术讲座 | 通知公告 |
| ------ | ----- |
| events | notes |

### 教务信息

<Route author="simonsmh" example="/shmtu/jwc/jwgg" path="/shmtu/jwc/:type" :paramsDesc="['类型名称']"/>
<Route author="imbytecat simonsmh" example="/shmtu/jwc/jwgg" path="/shmtu/jwc/:type" :paramsDesc="['类型名称']"/>

| 教务公告 | 教务新闻 |
| ---- | ---- |
Expand All @@ -2370,9 +2370,9 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS

<Route author="imbytecat" example="/shmtu/portal/bmtzgg" path="/shmtu/portal/:type" :paramsDesc="['类型名称']"/>

| 部门通知公告 |
| ------ |
| bmtzgg |
| 部门通知公告 | 学术与大型活动公告 | 部门动态 |
| ------ | --------- | ---- |
| bmtzgg | xsydxhdgg | bmdt |

## 上海海洋大学

Expand Down
1 change: 1 addition & 0 deletions lib/utils/wechat-mp.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* lib/v2/sdu/cs
* lib/v2/nua/utils
* lib/v2/hrbeu
* lib/v2/freewechat
*
* If your new route is not in the above folders, please add it to the list.
*
Expand Down
3 changes: 3 additions & 0 deletions lib/v2/freewechat/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/profile/:id': ['TonyRL'],
};
61 changes: 61 additions & 0 deletions lib/v2/freewechat/profile.js
Original file line number Diff line number Diff line change
@@ -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 changes: 13 additions & 0 deletions lib/v2/freewechat/radar.js
Original file line number Diff line number Diff line change
@@ -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 changes: 3 additions & 0 deletions lib/v2/freewechat/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/profile/:id', require('./profile'));
};
23 changes: 15 additions & 8 deletions lib/v2/mirror/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,23 @@ module.exports = async (ctx) => {

const data = JSON.parse(response.data.match(/"__NEXT_DATA__" type="application\/json">({"props":.*})<\/script>/)[1]);

const items = data.props.pageProps.project.posts.map((item) => ({
title: item.title,
description: md.render(item.truncatedBody),
link: `${currentUrl}/${item._id}`,
pubDate: parseDate(item.timestamp, 'X'),
author: item.publisher.project.displayName,
}));
const items = Object.keys(data.props.pageProps.__APOLLO_STATE__)
.filter((key) => key.startsWith('entry:'))
.map((key) => {
const item = data.props.pageProps.__APOLLO_STATE__[key];
return {
title: item.title,
description: md.render(item.body),
link: `${currentUrl}/${item._id}`,
pubDate: parseDate(item.publishedAtTimestamp, 'X'),
author: data.props.pageProps.publicationLayoutProject.displayName,
};
});

ctx.state.data = {
title: `${data.props.pageProps.project.displayName} - Mirror`,
title: `${data.props.pageProps.publicationLayoutProject.displayName} - Mirror`,
description: data.props.pageProps.publicationLayoutProject.description,
image: data.props.pageProps.publicationLayoutProject.avatarURL,
link: currentUrl,
item: items,
};
Expand Down
4 changes: 2 additions & 2 deletions lib/v2/shmtu/maintainer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
'/jwc/:type': ['simonsmh'],
'/jwc/:type': ['imbytecat', 'simonsmh'],
'/portal/:type': ['imbytecat'],
'/www/:type': ['simonsmh'],
'/www/:type': ['imbytecat', 'simonsmh'],
};
16 changes: 15 additions & 1 deletion lib/v2/shmtu/portal.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,21 @@ const processFeed = (list, caches) =>

module.exports = async (ctx) => {
const type = ctx.params.type;
const info = type === 'bmtzgg' ? '部门通知公告' : '未知';
let info;
switch (type) {
case 'bmtzgg':
info = '部门通知公告';
break;
case 'xsydxhdgg':
info = '学术与大型活动公告';
break;
case 'bmdt':
info = '部门动态';
break;
default:
info = '未知';
break;
}

const response = await got.post(bootstrapHost, {
form: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"request-promise-native": "1.0.9",
"staged-git-files": "1.3.0",
"string-width": "4.2.3",
"supertest": "6.3.2",
"supertest": "6.3.3",
"tosource": "2.0.0-alpha.3",
"unified": "9.2.2",
"vuepress": "1.9.7",
Expand Down
53 changes: 24 additions & 29 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4927,10 +4927,10 @@ [email protected]:
resolved "https://registry.yarnpkg.com/devtools-protocol/-/devtools-protocol-0.0.1068969.tgz#8b9a4bc48aed1453bed08d62b07481f9abf4d6d8"
integrity sha512-ATFTrPbY1dKYhPPvpjtwWKSK2mIwGmRwX54UASn9THEuIZCe2n9k3vVuMmt6jWeL+e5QaaguEv/pMyR+JQB7VQ==

[email protected].3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/dezalgo/-/dezalgo-1.0.3.tgz#7f742de066fc748bc8db820569dddce49bf0d456"
integrity sha512-K7i4zNfT2kgQz3GylDw40ot9GAE47sFZ9EXHFSPP6zONLgH6kWXE0KWJchkbQJLBkRazq4APwZ4OwiFFlT95OQ==
dezalgo@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/dezalgo/-/dezalgo-1.0.4.tgz#751235260469084c132157dfa857f386d4c33d81"
integrity sha512-rXSP0bf+5n0Qonsb+SVVfNfIsimO4HEtmnIpPHY8Q1UCzKlQrDMfdobr8nJOOsRgWCyMRqeSBQzmWUMq7zvVig==
dependencies:
asap "^2.0.0"
wrappy "1"
Expand Down Expand Up @@ -6310,15 +6310,15 @@ formidable@^1.2.0:
resolved "https://registry.yarnpkg.com/formidable/-/formidable-1.2.6.tgz#d2a51d60162bbc9b4a055d8457a7c75315d1a168"
integrity sha512-KcpbcpuLNOwrEjnbpMC0gS+X8ciDoZE1kkqzat4a8vrprf+s9pKNQ/QIwWfbfs4ltgmFl3MD177SNTkve3BwGQ==

formidable@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/formidable/-/formidable-2.0.1.tgz#4310bc7965d185536f9565184dee74fbb75557ff"
integrity sha512-rjTMNbp2BpfQShhFbR3Ruk3qk2y9jKpvMW78nJgx8QKtxjDVrwbZG+wvDOmVbifHyOUOQJXxqEy6r0faRrPzTQ==
formidable@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/formidable/-/formidable-2.1.1.tgz#81269cbea1a613240049f5f61a9d97731517414f"
integrity sha512-0EcS9wCFEzLvfiks7omJ+SiYJAiD+TzK4Pcw1UlUoGnhUxDcMKjt0P7x8wEb0u6OHu8Nb98WG3nxtlF5C7bvUQ==
dependencies:
dezalgo "1.0.3"
hexoid "1.0.0"
once "1.4.0"
qs "6.9.3"
dezalgo "^1.0.4"
hexoid "^1.0.0"
once "^1.4.0"
qs "^6.11.0"

[email protected]:
version "0.2.0"
Expand Down Expand Up @@ -6982,7 +6982,7 @@ hex-color-regex@^1.1.0:
resolved "https://registry.yarnpkg.com/hex-color-regex/-/hex-color-regex-1.1.0.tgz#4c06fccb4602fe2602b3c93df82d7e7dbf1a8a8e"
integrity sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ==

[email protected]:
hexoid@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/hexoid/-/hexoid-1.0.0.tgz#ad10c6573fb907de23d9ec63a711267d9dc9bc18"
integrity sha512-QFLV0taWQOZtvIRIAdBChesmogZrtuXvVWsFHZTk2SU+anspqZ2vMnoLg7IE1+Uk16N19APic1BuF8bC8c2m5g==
Expand Down Expand Up @@ -10308,7 +10308,7 @@ on-headers@~1.0.2:
resolved "https://registry.yarnpkg.com/on-headers/-/on-headers-1.0.2.tgz#772b0ae6aaa525c399e489adfad90c403eb3c28f"
integrity sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==

once@1.4.0, once@^1.3.0, once@^1.3.1, once@^1.4.0:
once@^1.3.0, once@^1.3.1, once@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==
Expand Down Expand Up @@ -11497,11 +11497,6 @@ [email protected], qs@^6.11.0, qs@^6.5.1, qs@^6.7.0:
dependencies:
side-channel "^1.0.4"

[email protected]:
version "6.9.3"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.9.3.tgz#bfadcd296c2d549f1dffa560619132c977f5008e"
integrity sha512-EbZYNarm6138UKKq46tdx08Yo/q9ZhFoAXAI1meAFd2GtbRDhbZY2WQSICskT0c5q99aFzLG1D4nvTk9tqfXIw==

qs@~6.5.2:
version "6.5.3"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.3.tgz#3aeeffc91967ef6e35c0e488ef46fb296ab76aad"
Expand Down Expand Up @@ -13033,29 +13028,29 @@ superagent@^3.8.2:
qs "^6.5.1"
readable-stream "^2.3.5"

superagent@^8.0.3:
version "8.0.3"
resolved "https://registry.yarnpkg.com/superagent/-/superagent-8.0.3.tgz#15c8ec5611a1f01386994cfeeda5aa138bcb7b17"
integrity sha512-oBC+aNsCjzzjmO5AOPBPFS+Z7HPzlx+DQr/aHwM08kI+R24gsDmAS1LMfza1fK+P+SKlTAoNZpOvooE/pRO1HA==
superagent@^8.0.5:
version "8.0.6"
resolved "https://registry.yarnpkg.com/superagent/-/superagent-8.0.6.tgz#e3fb0b3112b79b12acd605c08846253197765bf6"
integrity sha512-HqSe6DSIh3hEn6cJvCkaM1BLi466f1LHi4yubR0tpewlMpk4RUFFy35bKz8SsPBwYfIIJy5eclp+3tCYAuX0bw==
dependencies:
component-emitter "^1.3.0"
cookiejar "^2.1.3"
debug "^4.3.4"
fast-safe-stringify "^2.1.1"
form-data "^4.0.0"
formidable "^2.0.1"
formidable "^2.1.1"
methods "^1.1.2"
mime "2.6.0"
qs "^6.11.0"
semver "^7.3.8"

[email protected].2:
version "6.3.2"
resolved "https://registry.yarnpkg.com/supertest/-/supertest-6.3.2.tgz#7780b4b85bb2ea675c05b5cb80fa52f4dbe5a52b"
integrity sha512-mSmbW/sPpBU6K8w8189ZiHdc62zMe7dCHpC2ktS9tc0/d2DN0FaxNbDJJNFknZD4jCrGJpxkiFoVyemvKgOdwA==
[email protected].3:
version "6.3.3"
resolved "https://registry.yarnpkg.com/supertest/-/supertest-6.3.3.tgz#42f4da199fee656106fd422c094cf6c9578141db"
integrity sha512-EMCG6G8gDu5qEqRQ3JjjPs6+FYT1a7Hv5ApHvtSghmOFJYtsU5S+pSb6Y2EUeCEY3CmEL3mmQ8YWlPOzQomabA==
dependencies:
methods "^1.1.2"
superagent "^8.0.3"
superagent "^8.0.5"

supports-color@^5.3.0, supports-color@^5.5.0:
version "5.5.0"
Expand Down

1 comment on commit 87413fa

@vercel
Copy link

@vercel vercel bot commented on 87413fa Dec 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.