From 0dce8a0c0a91d89c87f53b6639160e9506fb2666 Mon Sep 17 00:00:00 2001 From: starry2048 <78544325+starry2048@users.noreply.github.com> Date: Wed, 3 Mar 2021 05:53:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(route):=20add=20pubDate=20for=20=E4=B8=AD?= =?UTF-8?q?=E5=9B=BD=E6=95=99=E8=82=B2=E8=80=83=E8=AF=95=E7=BD=91=20(#7088?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: rs --- lib/routes/neea/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/routes/neea/index.js b/lib/routes/neea/index.js index 451c70bd4d95dc..3e30893c3bf8c4 100644 --- a/lib/routes/neea/index.js +++ b/lib/routes/neea/index.js @@ -28,15 +28,20 @@ module.exports = async (ctx) => { const data = response.data; const $ = cheerio.load(data); - const list = $(`#ReportIDname > a`).get(); + const list = $(`#ReportIDname > a`).parent().parent().get(); const process = await Promise.all( list.map(async (item) => { - const itemUrl = `http://${type}.neea.edu.cn` + $(item).attr('href'); + const ReportIDname = $(item).find('#ReportIDname > a'); + const ReportIDIssueTime = $(item).find('#ReportIDIssueTime'); + const itemUrl = `http://${type}.neea.edu.cn` + $(ReportIDname).attr('href'); + let time = new Date(ReportIDIssueTime.text()).getTime(); + time += new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000; // beijing timezone const single = { - title: $(item).text(), + title: $(ReportIDname).text(), link: itemUrl, guid: itemUrl, + pubDate: new Date(time).toUTCString(), }; const other = await load(String(itemUrl), ctx); return Promise.resolve(Object.assign({}, single, other));