From 89ce36ffcf37384c205c6754bf92b2a8f2eccb89 Mon Sep 17 00:00:00 2001
From: Ethan Shen <42264778+nczitzk@users.noreply.github.com>
Date: Tue, 28 Nov 2023 08:23:57 +0800
Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E5=B9=BF=E4=B8=9C?=
=?UTF-8?q?=E7=9C=81=E9=A3=9F=E5=93=81=E8=8D=AF=E5=93=81=E5=AE=A1=E8=AF=84?=
=?UTF-8?q?=E8=AE=A4=E8=AF=81=E6=8A=80=E6=9C=AF=E5=8D=8F=E4=BC=9A=20(#1389?=
=?UTF-8?q?0)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
lib/v2/gdsrx/index.js | 72 +++++++++++++++++++++++++++++++++++
lib/v2/gdsrx/maintainer.js | 3 ++
lib/v2/gdsrx/radar.js | 61 +++++++++++++++++++++++++++++
lib/v2/gdsrx/router.js | 3 ++
website/docs/routes/other.mdx | 18 +++++++++
5 files changed, 157 insertions(+)
create mode 100644 lib/v2/gdsrx/index.js
create mode 100644 lib/v2/gdsrx/maintainer.js
create mode 100644 lib/v2/gdsrx/radar.js
create mode 100644 lib/v2/gdsrx/router.js
diff --git a/lib/v2/gdsrx/index.js b/lib/v2/gdsrx/index.js
new file mode 100644
index 00000000000000..7b9bbaf95b6496
--- /dev/null
+++ b/lib/v2/gdsrx/index.js
@@ -0,0 +1,72 @@
+const got = require('@/utils/got');
+const cheerio = require('cheerio');
+const { parseDate } = require('@/utils/parse-date');
+
+module.exports = async (ctx) => {
+ const { id = '10' } = ctx.params;
+ const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 15;
+
+ const rootUrl = 'http://www.gdsrx.org.cn';
+ const currentUrl = new URL(`portal/list/index/id/${id}.html`, rootUrl).href;
+
+ const { data: response } = await got(currentUrl);
+
+ const $ = cheerio.load(response);
+
+ let items = $('a.xn-item, a.t-item')
+ .slice(0, limit)
+ .toArray()
+ .map((item) => {
+ item = $(item);
+
+ return {
+ title: item.find('div.xn-d, div.t-e').text(),
+ link: new URL(item.prop('href'), rootUrl).href,
+ pubDate: parseDate(item.find('div.xn-time, div.t-f').text()),
+ };
+ });
+
+ items = await Promise.all(
+ items.map((item) =>
+ ctx.cache.tryGet(item.link, async () => {
+ const { data: detailResponse } = await got(item.link);
+
+ const content = cheerio.load(detailResponse);
+
+ const categories = content('a.nav-a')
+ .slice(1)
+ .toArray()
+ .map((c) => content(c).text());
+
+ item.title = categories.pop() || content('div.u-c').text();
+ item.description = content('div.u-f').html();
+ item.author = content('.author').text();
+ item.category = categories;
+ item.pubDate = parseDate(content('div.u-d').text());
+
+ return item;
+ })
+ )
+ );
+
+ const author = $('title').text();
+ const image = $('a.h-g img').prop('src');
+ const icon = new URL('favicon.ico', rootUrl).href;
+ const subtitle = $('a.nav-a')
+ .toArray()
+ .map((c) => $(c).text())
+ .pop();
+
+ ctx.state.data = {
+ item: items,
+ title: `${author} - ${subtitle}`,
+ link: currentUrl,
+ description: $('meta[name="description"]').prop('content'),
+ language: 'zh',
+ image,
+ icon,
+ logo: icon,
+ subtitle,
+ author,
+ };
+};
diff --git a/lib/v2/gdsrx/maintainer.js b/lib/v2/gdsrx/maintainer.js
new file mode 100644
index 00000000000000..77d283d85d8b6b
--- /dev/null
+++ b/lib/v2/gdsrx/maintainer.js
@@ -0,0 +1,3 @@
+module.exports = {
+ '/id?': ['nczitzk'],
+};
diff --git a/lib/v2/gdsrx/radar.js b/lib/v2/gdsrx/radar.js
new file mode 100644
index 00000000000000..f28dedb4226bb3
--- /dev/null
+++ b/lib/v2/gdsrx/radar.js
@@ -0,0 +1,61 @@
+module.exports = {
+ 'gdsrx.org.cn': {
+ _name: '广东省食品药品审评认证技术协会',
+ '.': [
+ {
+ title: '栏目',
+ docs: 'https://docs.rsshub.app/routes/other#guang-dong-sheng-shi-pin-yao-pin-shen-ping-ren-zheng-ji-shu-xie-hui-lan-mu',
+ source: ['/portal/list/index/id'],
+ target: (_, url) => {
+ url = new URL(url);
+
+ const idMatches = url.href.match(/\/id\/(\d+)\.html/);
+
+ return `/gdsrx${idMatches ? `/${idMatches[1]}` : ''}`;
+ },
+ },
+ {
+ title: '法规文库',
+ docs: 'https://docs.rsshub.app/routes/other#guang-dong-sheng-shi-pin-yao-pin-shen-ping-ren-zheng-ji-shu-xie-hui-lan-mu',
+ source: ['/portal/list/index/id/10.html'],
+ target: '/gdsrx/10',
+ },
+ {
+ title: '法规资讯',
+ docs: 'https://docs.rsshub.app/routes/other#guang-dong-sheng-shi-pin-yao-pin-shen-ping-ren-zheng-ji-shu-xie-hui-lan-mu',
+ source: ['/portal/list/index/id/12.html'],
+ target: '/gdsrx/12',
+ },
+ {
+ title: '专家供稿',
+ docs: 'https://docs.rsshub.app/routes/other#guang-dong-sheng-shi-pin-yao-pin-shen-ping-ren-zheng-ji-shu-xie-hui-lan-mu',
+ source: ['/portal/list/index/id/13.html'],
+ target: '/gdsrx/13',
+ },
+ {
+ title: '协会动态 会员动态',
+ docs: 'https://docs.rsshub.app/routes/other#guang-dong-sheng-shi-pin-yao-pin-shen-ping-ren-zheng-ji-shu-xie-hui-lan-mu',
+ source: ['/portal/list/index/id/20.html'],
+ target: '/gdsrx/20',
+ },
+ {
+ title: '协会动态',
+ docs: 'https://docs.rsshub.app/routes/other#guang-dong-sheng-shi-pin-yao-pin-shen-ping-ren-zheng-ji-shu-xie-hui-lan-mu',
+ source: ['/portal/list/index/id/37.html'],
+ target: '/gdsrx/37',
+ },
+ {
+ title: '协会通知公告',
+ docs: 'https://docs.rsshub.app/routes/other#guang-dong-sheng-shi-pin-yao-pin-shen-ping-ren-zheng-ji-shu-xie-hui-lan-mu',
+ source: ['/portal/list/index/id/38.html'],
+ target: '/gdsrx/38',
+ },
+ {
+ title: '会员动态',
+ docs: 'https://docs.rsshub.app/routes/other#guang-dong-sheng-shi-pin-yao-pin-shen-ping-ren-zheng-ji-shu-xie-hui-lan-mu',
+ source: ['/portal/list/index/id/39.html'],
+ target: '/gdsrx/39',
+ },
+ ],
+ },
+};
diff --git a/lib/v2/gdsrx/router.js b/lib/v2/gdsrx/router.js
new file mode 100644
index 00000000000000..a5d65c468f4c46
--- /dev/null
+++ b/lib/v2/gdsrx/router.js
@@ -0,0 +1,3 @@
+module.exports = (router) => {
+ router.get('/:id?', require('./'));
+};
diff --git a/website/docs/routes/other.mdx b/website/docs/routes/other.mdx
index aaaa5f9c72583a..2bc0b343b34898 100644
--- a/website/docs/routes/other.mdx
+++ b/website/docs/routes/other.mdx
@@ -879,6 +879,24 @@ Refer to [the list of supported currencies](https://wise.com/tools/exchange-rate
+## 广东省食品药品审评认证技术协会 {#guang-dong-sheng-shi-pin-yao-pin-shen-ping-ren-zheng-ji-shu-xie-hui}
+
+### 栏目 {#guang-dong-sheng-shi-pin-yao-pin-shen-ping-ren-zheng-ji-shu-xie-hui-lan-mu}
+
+
+
+| 栏目名称 | 栏目 id |
+| ----------------- | ------- |
+| 法规文库 | 10 |
+| 法规资讯 | 12 |
+| 专家供稿 | 13 |
+| 协会动态 会员动态 | 20 |
+| 协会动态 | 37 |
+| 协会通知公告 | 38 |
+| 会员动态 | 39 |
+
+
+
## 国家留学网 {#guo-jia-liu-xue-wang}
### 通知 {#guo-jia-liu-xue-wang-tong-zhi}