mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +08:00
feat: add 网易号 (#3087)
* Update router.js * Update new-media.md * Create dy.js
This commit is contained in:
@@ -614,7 +614,19 @@ pageClass: routes
|
||||
<Route author="HenryQW" example="/sohu/mp/119097" path="/sohu/mp/:id" :paramsDesc="['搜狐号 ID', '见如下说明']">
|
||||
|
||||
1. 通过浏览器搜索相关搜狐号 `果壳 site: mp.sohu.com`。
|
||||
1. 通过浏览器控制台执行 `cfgs.author_id`,返回的即为搜狐号 ID。
|
||||
2. 通过浏览器控制台执行 `cfgs.author_id`,返回的即为搜狐号 ID。
|
||||
|
||||
</Route>
|
||||
|
||||
## 网易号
|
||||
|
||||
### 更新
|
||||
|
||||
<Route author="HendricksZheng" example="/netease/dy/W4983108759592548559" path="/netease/dy/:id" :paramsDesc="['网易号 ID', '见如下说明']">
|
||||
|
||||
1. 在[网易号搜索页面](https://dy.163.com/v2/media/tosearch.html) 搜索想要订阅的网易号。
|
||||
2. 打开网易号文章页面。
|
||||
3. 通过浏览器控制台执行 `$('#contain').dataset.wemediaid`,返回的即为网易号 ID。
|
||||
|
||||
</Route>
|
||||
|
||||
|
||||
@@ -1729,4 +1729,7 @@ router.get('/leemeng', require('./routes/blogs/leemeng'));
|
||||
// 中国地质大学
|
||||
router.get('/cug/graduate', require('./routes/cug/graduate'));
|
||||
|
||||
// 网易 - 网易号
|
||||
router.get('/netease/dy/:id', require('./routes/netease/dy'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
49
lib/routes/netease/dy.js
Normal file
49
lib/routes/netease/dy.js
Normal file
@@ -0,0 +1,49 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const date = require('@/utils/date');
|
||||
const iconv = require('iconv-lite');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id } = ctx.params;
|
||||
|
||||
const response = await got.get(`http://dy.163.com/v2/article/list.do?pageNo=1&wemediaId=${id}&size=10`);
|
||||
|
||||
const list = response.data.data.list;
|
||||
let author, link;
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(async (e) => {
|
||||
if (e.docid) {
|
||||
e.link = 'http://dy.163.com/v2/article/detail/' + e.docid + '.html';
|
||||
}
|
||||
const response = await ctx.cache.tryGet(
|
||||
e.link,
|
||||
async () =>
|
||||
(await got.get(e.link, {
|
||||
responseType: 'buffer',
|
||||
})).data
|
||||
);
|
||||
const html = iconv.decode(response, 'gbk');
|
||||
const $ = cheerio.load(html, { decodeEntities: false });
|
||||
|
||||
const article = $('div.article_box > div.content');
|
||||
|
||||
const single = {
|
||||
title: e.title,
|
||||
link: e.link,
|
||||
description: article.html(),
|
||||
pubDate: date(e.ptime, 8),
|
||||
author: e.source,
|
||||
};
|
||||
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `网易号 - ${author}`,
|
||||
link,
|
||||
description: '',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user