feat: add interesting sky (#6453)
This commit is contained in:
parent
de2bd58daa
commit
9790957b20
|
|
@ -1918,6 +1918,12 @@ column 为 third 时可选的 category:
|
|||
|
||||
</Route>
|
||||
|
||||
## 有趣天文奇观
|
||||
|
||||
### 首页
|
||||
|
||||
<Route author="nczitzk" example="/interesting-sky" path="/interesting-sky"/>
|
||||
|
||||
## 遠見
|
||||
|
||||
<Route author="laampui" example="/gvm/index/health" path="/gvm/index/:category?" :paramsDesc="['見下表, 默認爲 newest']">
|
||||
|
|
|
|||
|
|
@ -3710,4 +3710,7 @@ router.get('/cmes/news/:category?', require('./routes/cmes/news'));
|
|||
// Craigslist
|
||||
router.get('/craigslist/:location/:type', require('./routes/craigslist/search'));
|
||||
|
||||
// 有趣天文奇观
|
||||
router.get('/interesting-sky', require('./routes/interesting-sky/index'));
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://interesting-sky.china-vo.org';
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: rootUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const items = $('article')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
|
||||
const title = item.find('.entry-title a');
|
||||
|
||||
return {
|
||||
title: title.text(),
|
||||
link: title.attr('href'),
|
||||
author: item.find('.author').text(),
|
||||
description: item.find('.article_content').html(),
|
||||
pubDate: new Date(item.find('time.entry-date').attr('datetime')).toUTCString(),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: '有趣天文奇观 - Interesting Sky',
|
||||
link: rootUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue