Merge branch 'master' into eventernote
This commit is contained in:
commit
5f5e9ed235
|
|
@ -449,6 +449,10 @@ pageClass: routes
|
|||
|
||||
<Route author="changlan" example="/wenxuecity/bbs/tzlc" path="/wenxuecity/bbs/:cat/:elite?" :paramsDesc="['版面名, 可在 URL 中找到', '是否精华区, 1 为精华区']" radar="1" />
|
||||
|
||||
### 焦点新闻
|
||||
|
||||
<Route author="nczitzk" example="/wenxuecity/news" path="/wenxuecity/news" />
|
||||
|
||||
## 小米社区
|
||||
|
||||
### 圈子
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的
|
|||
|
||||
| Switch | PS5 | PS4 | XboxOne | XboxSX | PC 單機 | PC 線上 | iOS | Android | Web | 漫畫 | 動畫 |
|
||||
| ------ | --- | --- | ------- | ------ | ------- | ------- | --- | ------- | --- | ----- | ----- |
|
||||
| ns | ps5 | ps4 | xbone | xbsx | pc | olg | ios | android | web | comic | anime |
|
||||
| ns | ps5 | ps4 | xbone | xbsx | pc | olg | ios | android | web | comic | anime |
|
||||
|
||||
</Route>
|
||||
|
||||
|
|
|
|||
|
|
@ -3198,6 +3198,7 @@ router.get('/itslaw/judgements/:conditions', require('./routes/itslaw/judgements
|
|||
router.get('/wenxuecity/blog/:id', require('./routes/wenxuecity/blog'));
|
||||
router.get('/wenxuecity/bbs/:cat/:elite?', require('./routes/wenxuecity/bbs'));
|
||||
router.get('/wenxuecity/hot/:cid', require('./routes/wenxuecity/hot'));
|
||||
router.get('/wenxuecity/news', require('./routes/wenxuecity/news'));
|
||||
|
||||
// 不安全
|
||||
router.get('/buaq', require('./routes/buaq/index'));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://www.wenxuecity.com';
|
||||
const currentUrl = `${rootUrl}/news/`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
https: {
|
||||
rejectUnauthorized: false,
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('div.mainwrap div.block div.wrapper ul li a')
|
||||
.slice(0, 15)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.text(),
|
||||
link: `${rootUrl}${item.attr('href')}`,
|
||||
};
|
||||
})
|
||||
.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,
|
||||
https: {
|
||||
rejectUnauthorized: false,
|
||||
},
|
||||
headers: {
|
||||
Referer: currentUrl,
|
||||
},
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('#articleContent').html();
|
||||
item.pubDate = new Date(content('time[itemprop="datePublished"]').text() + ' GMT+8').toUTCString();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '焦点新闻 - 文学城',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue