parent
5b2ab0605c
commit
15c7fa9468
|
|
@ -204,6 +204,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
|
|||
- 早报
|
||||
- 维基百科
|
||||
- 中国大陆新闻动态
|
||||
- 中国美术馆
|
||||
- 通知公告
|
||||
|
||||
</details>
|
||||
|
||||
|
|
|
|||
|
|
@ -1646,3 +1646,13 @@ id, 专辑 id, 可在对应专辑页面的 URL 中找到
|
|||
路由: `/wikipedia/mainland`
|
||||
|
||||
参数:无
|
||||
|
||||
## 中国美术馆
|
||||
|
||||
### 通知公告
|
||||
|
||||
举例: [https://rsshub.app/namoc/announcement](https://rsshub.app/namoc/announcement)
|
||||
|
||||
路由: `/namoc/announcement`
|
||||
|
||||
参数:无
|
||||
|
|
|
|||
|
|
@ -372,6 +372,9 @@ router.get('/keep/user/:id', require('./routes/keep/user'));
|
|||
router.get('/qidian/chapter/:id', require('./routes/qidian/chapter'));
|
||||
router.get('/qidian/forum/:id', require('./routes/qidian/forum'));
|
||||
|
||||
// 中国美术馆
|
||||
router.get('/namoc/announcement', require('./routes/namoc/announcement'));
|
||||
|
||||
// 懂球帝
|
||||
router.get('/dongqiudi/daily', require('./routes/dongqiudi/index'));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
const axios = require('../../utils/axios');
|
||||
const config = require('../../config');
|
||||
const cheerio = require('cheerio');
|
||||
const url = require('url');
|
||||
|
||||
const _axios_client = axios.create({
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
},
|
||||
});
|
||||
|
||||
const host = 'http://www.namoc.org/xwzx/tzgg/2017gonggao/';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await _axios_client.get(host);
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.news-list li:not(.clearfix)').slice(0, 10);
|
||||
const out = [];
|
||||
const proList = [];
|
||||
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const $ = cheerio.load(list[i]);
|
||||
const title = $('a').text();
|
||||
const itemUrl = url.resolve(host, $('a').attr('href'));
|
||||
const cache = await ctx.cache.get(itemUrl);
|
||||
if (cache) {
|
||||
out.push(JSON.parse(cache));
|
||||
continue;
|
||||
}
|
||||
const single = {
|
||||
title,
|
||||
link: itemUrl,
|
||||
guid: itemUrl,
|
||||
};
|
||||
|
||||
try {
|
||||
const es = _axios_client.get(itemUrl);
|
||||
proList.push(es);
|
||||
out.push(single);
|
||||
} catch (err) {
|
||||
console.log(`${title}: ${itemUrl} -- ${err.response.status}: ${err.response.statusText}`);
|
||||
}
|
||||
}
|
||||
|
||||
const responses = await axios.all(proList);
|
||||
for (let i = 0; i < responses.length; i++) {
|
||||
const $ = cheerio.load(responses[i].data);
|
||||
const full = $('#content');
|
||||
|
||||
out[i].description = full.find('div.Custom_UnionStyle').html();
|
||||
out[i].author = '中国美术馆';
|
||||
out[i].pubDate = new Date(
|
||||
full
|
||||
.find('.news-info span:last-of-type')
|
||||
.text()
|
||||
.replace('时间:', '')
|
||||
).toUTCString();
|
||||
ctx.cache.set(out[i].link, JSON.stringify(out[i]), 24 * 60 * 60);
|
||||
}
|
||||
ctx.state.data = {
|
||||
title: '中国美术馆 -- 通知公告',
|
||||
link: 'http://www.namoc.org/xwzx/tzgg/2017gonggao/',
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue