From ebe40f0a48b855f25d3b591932462996c531f979 Mon Sep 17 00:00:00 2001 From: Chenyang Shi Date: Fri, 26 Apr 2019 10:44:09 +0800 Subject: [PATCH] fix Apple Exchange and Repair Extension Programs returns 404 (#1996) * update bug report template * fix Apple Exchange and Repair Extension Programs returns 404 --- lib/routes/apple/exchange_repair.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/routes/apple/exchange_repair.js b/lib/routes/apple/exchange_repair.js index 2780c47e1..371e07d03 100644 --- a/lib/routes/apple/exchange_repair.js +++ b/lib/routes/apple/exchange_repair.js @@ -21,6 +21,10 @@ module.exports = async (ctx) => { .map((i, e) => $(e).attr('href')) .get(); + const titlelist = $('tr td a') + .map((i, e) => $(e).text()) + .get(); + const datelist = $('tr td p') .map((i, e) => $(e) @@ -39,14 +43,17 @@ module.exports = async (ctx) => { const response = await axios.get(itemUrl); const $ = cheerio.load(response.data); + const description = $('#welcome').html() + ? $('#welcome') + .html() + .replace(/src="\//g, `src="${url.resolve(host, '.')}`) + : null; const single = { - title: $('h1').text(), + title: titlelist[index], link: itemUrl, author: 'Apple Inc.', - description: $('#welcome') - .html() - .replace(/src="\//g, `src="${url.resolve(host, '.')}`), + description: description, pubDate: new Date(datelist[index].replace(/(\d+) 年 (\d+) 月 (\d+) 日/, '$1-$2-$3')).toISOString(), };