fix(route): add pubDate for 中国教育考试网 (#7088)

Co-authored-by: rs <rs@rs-tower20>
This commit is contained in:
starry2048
2021-03-02 16:53:22 -05:00
committed by GitHub
co-authored by rs
parent bfff2c55d3
commit 0dce8a0c0a
+8 -3
View File
@@ -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));