diff --git a/lib/routes/jinshi/index.js b/lib/routes/jinshi/index.js index 359af74610..7cda664766 100644 --- a/lib/routes/jinshi/index.js +++ b/lib/routes/jinshi/index.js @@ -4,28 +4,32 @@ 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; + let date; - $('#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}`); + const item = $('#jin_flash_list .jin-flash-item-container') + .filter((index, ele) => !!$('.right-content div:first-of-type', ele).text() && !$('.is-vip', ele).length) + .map((index, ele) => { + const year = new Date().getFullYear(); + const time = $('.item-time', ele).text(); + const title = $('.right-content div:first-of-type', ele).text(); + const link = $('.right-content .flash-item-share_right a', ele).attr('href'); + + date = $('.jin-flash-date-line span', ele).text().trim() ? $('.jin-flash-date-line span', ele).text().trim() : date; + + const datetime = year + '-' + date.replace('月', '-').replace('日', ` ${time}`); + + return { + title, + link, + description: datetime, + pubDate: new Date(datetime), + }; + }) + .get(); - 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, + item, }; };