diff --git a/lib/v2/ielts/index.js b/lib/v2/ielts/index.js index 9c8434d31..343b5773a 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 html = await page.evaluate(() => document.body.innerHTML); + 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(), + }; + }) + ); 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);