mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat: add 中国科学院青年创新促进会最新博文 (#6519)
This commit is contained in:
@@ -2032,6 +2032,12 @@ column 为 third 时可选的 category:
|
||||
|
||||
</Route>
|
||||
|
||||
## 中国科学院青年创新促进会
|
||||
|
||||
### 最新博文
|
||||
|
||||
<Route author="nczitzk" example="/yicas/blog" path="/yicas/blog"/>
|
||||
|
||||
## 中国劳工观察
|
||||
|
||||
### 调查报告
|
||||
|
||||
@@ -3744,6 +3744,9 @@ router.get('/idaily/today', require('./routes/idaily/index'));
|
||||
// 北屋
|
||||
router.get('/northhouse/:category?', require('./routes/northhouse/index'));
|
||||
|
||||
// 中国科学院青年创新促进会
|
||||
router.get('/yicas/blog', require('./routes/yicas/blog'));
|
||||
|
||||
// 九三学社
|
||||
router.get('/93/:category?', require('./routes/93/index'));
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const iconv = require('iconv-lite');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'http://yicas.cn';
|
||||
const currentUrl = `${rootUrl}/portal.php?mod=blog`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
responseType: 'buffer',
|
||||
});
|
||||
|
||||
const $ = cheerio.load(iconv.decode(response.data, 'gbk'));
|
||||
|
||||
const list = $('tr td a[title]')
|
||||
.slice(0, 15)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.text(),
|
||||
link: item.attr('href'),
|
||||
pubDate: new Date(item.next().text()).toUTCString(),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
responseType: 'buffer',
|
||||
});
|
||||
const content = cheerio.load(iconv.decode(detailResponse.data, 'gbk'));
|
||||
|
||||
item.author = content('.xs2').text();
|
||||
item.description = content('#blog_article').html();
|
||||
item.pubDate = new Date(content('.xg1').eq(5).text()).toUTCString();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user