feat: add zhihu follow timeline (#6560)
This commit is contained in:
parent
9a8b432c82
commit
170a6428d1
|
|
@ -619,3 +619,8 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行
|
|||
|
||||
- `DIDA365_USERNAME`: 滴答清单用户名
|
||||
- `DIDA365_PASSWORD`: 滴答清单密码
|
||||
|
||||
- 知乎用户关注时间线
|
||||
|
||||
- `ZHIHU_COOKIES`: 知乎登录后的 cookie 值.
|
||||
1. 可以在知乎网页版的一些请求的请求头中找到,如 `GET /moments` 请求头中的 `cookie` 值.
|
||||
|
|
|
|||
|
|
@ -1141,3 +1141,12 @@ rule
|
|||
### 知乎书店 - 知乎周刊
|
||||
|
||||
<Route author="LogicJake" example="/zhihu/weekly" path="/zhihu/weekly" anticrawler="1" radar="1" rssbud="1"/>
|
||||
|
||||
### 用户关注时间线
|
||||
|
||||
<Route author="SeanChao" example="/zhihu/timeline" path="/zhihu/timeline" anticrawler="1" selfhost="1"/>
|
||||
::: warning 注意
|
||||
|
||||
用户关注动态需要登录后的 Cookie 值,所以只能自建,详情见部署页面的配置模块。
|
||||
|
||||
:::
|
||||
|
|
|
|||
|
|
@ -89,6 +89,9 @@ const calculateValue = () => {
|
|||
yuque: {
|
||||
token: envs.YUQUE_TOKEN,
|
||||
},
|
||||
zhihu: {
|
||||
cookies: envs.ZHIHU_COOKIES,
|
||||
},
|
||||
puppeteerWSEndpoint: envs.PUPPETEER_WS_ENDPOINT,
|
||||
loggerLevel: envs.LOGGER_LEVEL || 'info',
|
||||
proxyUri: envs.PROXY_URI,
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@ router.get('/zhihu/people/pins/:id', require('./routes/zhihu/pin/people'));
|
|||
router.get('/zhihu/bookstore/newest', require('./routes/zhihu/bookstore/newest'));
|
||||
router.get('/zhihu/pin/daily', require('./routes/zhihu/pin/daily'));
|
||||
router.get('/zhihu/weekly', require('./routes/zhihu/weekly'));
|
||||
router.get('/zhihu/timeline', require('./routes/zhihu/timeline'));
|
||||
|
||||
// 妹子图
|
||||
router.get('/mzitu/home/:type?', require('./routes/mzitu/home'));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
const got = require('@/utils/got');
|
||||
const config = require('@/config').value;
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const cookie = config.zhihu.cookies;
|
||||
if (cookie === undefined) {
|
||||
throw Error('缺少知乎用户登录后的 Cookie 值');
|
||||
}
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://www.zhihu.com/api/v3/moments?limit=10`,
|
||||
headers: {
|
||||
Cookie: cookie,
|
||||
},
|
||||
});
|
||||
const feeds = response.data.data;
|
||||
|
||||
const out = feeds.map((e) => ({
|
||||
title: `${e.action_text}: ${e.target.title ? e.target.title : e.target.question.title}`,
|
||||
description: `${e.target.excerpt}`,
|
||||
pubDate: new Date(e.updated_time * 1000),
|
||||
link: e.target.url.replace('api.zhihu.com', 'zhihu.com'),
|
||||
author: e.target.author.name,
|
||||
guid: e.id,
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
title: `知乎关注动态`,
|
||||
link: `https://www.zhihu.com/follow`,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue