From 50d31266c86eb8bd1ac9124fb82508af402a7cc8 Mon Sep 17 00:00:00 2001 From: Laam Pui Date: Sat, 26 Dec 2020 13:49:31 +0800 Subject: [PATCH] fix: outdated route DoNews (#6522) --- docs/new-media.md | 6 +++--- lib/routes/donews/index.js | 3 +-- lib/routes/donews/utils.js | 10 +++------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/docs/new-media.md b/docs/new-media.md index 22ec42b400..679acab72b 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -164,9 +164,9 @@ pageClass: routes -| 首页 | 商业 | 创业 | 互娱 | 科技 | 专栏 | -| ---- | ------- | -------- | ---- | ---------- | ------- | -| (空) | company | business | ent | technology | idonews | +| 首页 | 商业 | 创业 | 互娱 | 科技 | 专栏 | +| ---- | ------- | -------- | ---- | ------- | ------- | +| (空) | company | business | ent | digital | idonews | diff --git a/lib/routes/donews/index.js b/lib/routes/donews/index.js index 0e4e0cb096..41870a5fcb 100644 --- a/lib/routes/donews/index.js +++ b/lib/routes/donews/index.js @@ -28,8 +28,7 @@ module.exports = async (ctx) => { switch (column) { case '': // 首页轮播 - list = $('.focues.hide > ul > li > a').get(); - list = list.concat($('.fl.w840 > .block > dl > dd > h3 > a').slice(0, 7).get()); + list = $('a.news-item').get(); break; case 'ent': diff --git a/lib/routes/donews/utils.js b/lib/routes/donews/utils.js index b3f14d368a..73769b8375 100644 --- a/lib/routes/donews/utils.js +++ b/lib/routes/donews/utils.js @@ -1,19 +1,15 @@ const cheerio = require('cheerio'); const got = require('@/utils/got'); -const date = require('@/utils/date'); const ProcessFeed = async (link) => { const response = await got.get(link); - const $ = cheerio.load(response.data); - const meta = $($('#main .fl')[0]); - return { - title: $('h1').text() || $($('h2')[1]).text(), - author: meta.find('span:nth-child(1)').text(), + title: $('.detail-con h1').text() || $('.detail-con h2').text().replace('{{news.title}}', ''), + author: $('.tag > .fl > span:nth-child(2)').text().replace('{{news.author}}', ''), description: $('.article-con').html(), - pubDate: date(meta.find('span:nth-child(2)').text(), 8), + pubDate: new Date($('.tag > .fl > span:nth-child(1)').text().replace('{{news.timeFormat}}', '')), link, }; };