From aed981c4ffdb815267903c7421f59aa6ce556cb8 Mon Sep 17 00:00:00 2001 From: Laam Pui Date: Fri, 30 Oct 2020 17:29:29 +0800 Subject: [PATCH] feat: add jin10.com (#6008) close #5778 --- docs/finance.md | 3 +++ lib/router.js | 3 +++ lib/routes/jinshi/index.js | 31 +++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 lib/routes/jinshi/index.js diff --git a/docs/finance.md b/docs/finance.md index 85431a16f..7879175ab 100644 --- a/docs/finance.md +++ b/docs/finance.md @@ -62,6 +62,9 @@ pageClass: routes <Route author="nczitzk" example="/gelonghui/keyword/ 早报" path="/gelonghui/keyword/:keyword" :paramsDesc="[' 搜索关键字']/> +## 金十数据 + + ## 世界经济论坛 ### 报告 diff --git a/lib/router.js b/lib/router.js index aadb3bb7b..09d301033 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1868,6 +1868,9 @@ router.get('/im2maker/:channel?', require('./routes/im2maker/index')); // 巨潮资讯 router.get('/cninfo/announcement/:column/:code/:orgId/:category?', require('./routes/cninfo/announcement')); +// 金十数据 +router.get('/jinshi/index', require('./routes/jinshi/index')); + // 中央纪委国家监委网站 router.get('/ccdi/scdc', require('./routes/ccdi/scdc')); diff --git a/lib/routes/jinshi/index.js b/lib/routes/jinshi/index.js new file mode 100644 index 000000000..359af7461 --- /dev/null +++ b/lib/routes/jinshi/index.js @@ -0,0 +1,31 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const response = await got.get('https://www.jin10.com/'); + const $ = cheerio.load(response.data); + const item = []; + let month_day; + + $('#jin_flash_list .jin-flash-item-container').each((index, ele) => { + const year = new Date().getFullYear(); + const new_month_day = $('.jin-flash-date-line span', ele).text().trim(); + new_month_day && (month_day = new_month_day); + const month = month_day.match(/\d+/g)[0]; + const day = month_day.match(/\d+/g)[1]; + const time = $('.item-time', ele).text(); + const date = new Date(`${year}-${month}-${day} ${time}`); + + item.push({ + title: $('.right-content div:first-of-type', ele).text(), + link: $('.right-content .flash-item-share_right a', ele).attr('href'), + description: `${year}-${month}-${day} ${time}`, + pubDate: date.toUTCString(), + }); + }); + ctx.state.data = { + title: '金十数据', + link: 'https://www.jin10.com/', + item: item, + }; +};