From 7ee226708234ee9f757038ea742ae13cf5faf379 Mon Sep 17 00:00:00 2001 From: nczitzk Date: Sat, 10 Oct 2020 11:49:21 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20add=20=E6=96=87=E5=AD=A6=E5=9F=8E?= =?UTF-8?q?=E7=84=A6=E7=82=B9=E6=96=B0=E9=97=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/bbs.md | 4 +++ lib/router.js | 1 + lib/routes/wenxuecity/news.js | 56 +++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 lib/routes/wenxuecity/news.js diff --git a/docs/bbs.md b/docs/bbs.md index 817c38466..5d2a54f61 100644 --- a/docs/bbs.md +++ b/docs/bbs.md @@ -449,6 +449,10 @@ +### 焦点新闻 + + + ## 小米社区 ### 圈子 diff --git a/lib/router.js b/lib/router.js index e2ee2c7e5..4505a9653 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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')); diff --git a/lib/routes/wenxuecity/news.js b/lib/routes/wenxuecity/news.js new file mode 100644 index 000000000..3d090f420 --- /dev/null +++ b/lib/routes/wenxuecity/news.js @@ -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, + }; +}; From 33db3a8cf3e323a15b9e253e84a4b92feacae78b Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sat, 10 Oct 2020 14:32:43 +0000 Subject: [PATCH 2/2] style: auto format --- docs/game.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/game.md b/docs/game.md index 1efda17af..d3f5c72bc 100644 --- a/docs/game.md +++ b/docs/game.md @@ -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 |