diff --git a/lib/v2/ielts/index.js b/lib/v2/ielts/index.js index 343b5773a..9c8434d31 100644 --- a/lib/v2/ielts/index.js +++ b/lib/v2/ielts/index.js @@ -15,21 +15,21 @@ module.exports = async (ctx) => { await page.goto(targetUrl, { waitUntil: 'networkidle0', }); - const list = await page.evaluate(() => - window - .$('#newsListUl li') - .get() - .map((elem) => { - const $elem = window.$(elem); - return { - title: $elem.find('a').text(), - link: $elem.find('a').attr('href'), - pubDate: $elem.find('span').eq(-1).text().replace(/[[\]]/g, '').trim(), - }; - }) - ); + const html = await page.evaluate(() => document.body.innerHTML); browser.close(); + const $ = cheerio.load(html); + const list = $('#newsListUl li') + .get() + .map((elem) => { + const $elem = $(elem); + return { + title: $elem.find('a').text(), + link: $elem.find('a').attr('href'), + pubDate: $elem.find('span').eq(-1).text().replace(/[[\]]/g, '').trim(), + }; + }); + list.sort((a, b) => parseDate(b.pubDate) - parseDate(a.pubDate)); list.forEach((item) => { item.pubDate = timezone(parseDate(item.pubDate), +8);