From 8bb8e1fcb26cbe0dc1d3794cb650ea1f9fd24160 Mon Sep 17 00:00:00 2001 From: zekin Date: Tue, 25 May 2021 21:33:59 +0800 Subject: [PATCH] fix(route): bupt (#7489) --- docs/install/README.md | 9 +++++++++ docs/university.md | 12 ++++++++++++ lib/config.js | 3 +++ lib/routes/universities/bupt/news.js | 7 +++++++ lib/routes/universities/bupt/portal.js | 7 +++++++ 5 files changed, 38 insertions(+) diff --git a/docs/install/README.md b/docs/install/README.md index e45a9d1568fd69..ca1231d59e69f9 100644 --- a/docs/install/README.md +++ b/docs/install/README.md @@ -613,6 +613,15 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行 注意,暂不支持两步验证。 +- BUPT + + - `BUPT_PORTAL_COOKIE`: 登录后获得的 Cookie 值, 获取方式 + 1. 打开并登录 + 2. 无视掉报错,并打开 + 3. 打开控制台,刷新 + 4. 找到 请求 + 5. 找到请求头中的 Cookie + - BTBYR - `BTBYR_HOST`: 支持 ipv4 访问的 BTBYR 镜像,默认为原站 `https://bt.byr.cn/`。 diff --git a/docs/university.md b/docs/university.md index fb283a69bbfea5..b451a25aea07d0 100644 --- a/docs/university.md +++ b/docs/university.md @@ -242,10 +242,22 @@ pageClass: routes +::: warning 注意 + +由于需要登陆 `https://webapp.bupt.edu.cn/wap/login.html?redirect=http://` 后的 Cookie 值,所以只能自建,详情见部署页面的配置模块 + +::: + ### 校园新闻 +::: warning 注意 + +由于需要登陆 `https://webapp.bupt.edu.cn/wap/login.html?redirect=http://` 后的 Cookie 值,所以只能自建,详情见部署页面的配置模块 + +::: + ### BTBYR 趣味盒 diff --git a/lib/config.js b/lib/config.js index 3dbf731e76c5bb..387acc21d51780 100644 --- a/lib/config.js +++ b/lib/config.js @@ -131,6 +131,9 @@ const calculateValue = () => { pkubbs: { cookie: envs.PKUBBS_COOKIE, }, + bupt: { + portal_cookie: envs.BUPT_PORTAL_COOKIE, + }, nhentai: { username: envs.NHENTAI_USERNAME, password: envs.NHENTAI_PASSWORD, diff --git a/lib/routes/universities/bupt/news.js b/lib/routes/universities/bupt/news.js index 20415b9a41511e..de2e0bc1a19dbf 100644 --- a/lib/routes/universities/bupt/news.js +++ b/lib/routes/universities/bupt/news.js @@ -1,9 +1,16 @@ +const config = require('@/config').value; const got = require('@/utils/got'); module.exports = async (ctx) => { + const cookie = config.bupt.portal_cookie; + const headers = {}; + if (cookie) { + headers.cookie = cookie; + } const response = await got({ method: 'get', url: `https://webapp.bupt.edu.cn/extensions/wap/news/get-list.html?p=1&type=xnxw`, + headers, }); const out = []; const data = response.data.data; diff --git a/lib/routes/universities/bupt/portal.js b/lib/routes/universities/bupt/portal.js index 666358ef2e6717..2ea4c31890bed7 100644 --- a/lib/routes/universities/bupt/portal.js +++ b/lib/routes/universities/bupt/portal.js @@ -1,9 +1,16 @@ +const config = require('@/config').value; const got = require('@/utils/got'); module.exports = async (ctx) => { + const cookie = config.bupt.portal_cookie; + const headers = {}; + if (cookie) { + headers.cookie = cookie; + } const response = await got({ method: 'get', url: `https://webapp.bupt.edu.cn/extensions/wap/news/get-list.html?p=1&type=tzgg`, + headers, }); const out = []; const data = response.data.data;