fix(route): add tophub cookie (#13104)

* fix(route): add tophub cookie

* add docs for tophub cookie

* Update docs

* docs: reorder env
This commit is contained in:
JimenezLi
2023-08-23 20:36:08 +08:00
committed by GitHub
parent 53acb7f3f5
commit 8e4f814ea6
4 changed files with 20 additions and 1 deletions
+3
View File
@@ -275,6 +275,9 @@ const calculateValue = () => {
telegram: {
token: envs.TELEGRAM_TOKEN,
},
tophub: {
cookie: envs.TOPHUB_COOKIE,
},
twitter: {
consumer_key: envs.TWITTER_CONSUMER_KEY,
consumer_secret: envs.TWITTER_CONSUMER_SECRET,
+7 -1
View File
@@ -1,11 +1,17 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const config = require('@/config').value;
module.exports = async (ctx) => {
const id = ctx.params.id;
const link = `https://tophub.today/n/${id}`;
const response = await got.get(link);
const response = await got.get(link, {
headers: {
Referer: 'https://tophub.today',
Cookie: config.tophub.cookie,
},
});
const $ = cheerio.load(response.data);
const title = $('div.Xc-ec-L.b-L').text().trim();
+6
View File
@@ -3053,6 +3053,12 @@ others = 热点新闻 + 滚动新闻
## 今日热榜 {#jin-ri-re-bang}
:::caution
由于需要登录后的 Cookie 值才能获取原始链接,所以需要自建,需要在环境变量中配置 `TOPHUB_COOKIE`,详情见部署页面的配置模块。
:::
### 榜单 {#jin-ri-re-bang-bang-dan}
<Route author="LogicJake" example="/tophub/Om4ejxvxEN" path="/tophub/:id" paramsDesc={['榜单id,可在 URL 中找到']}/>
@@ -977,6 +977,10 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行
- `HEFENG_KEY`:API key
- 今日热榜
- `TOPHUB_COOKIE`: 今日热榜登录后的 cookie,目前只需要 `itc_center_user=...` 以获取原始链接
- 南方周末付费全文
- `INFZM_COOKIE`: infzm 账户登陆后的 cookie,目前只需要 `passport_session=...` 即可获取全文