fix(route): ielts window.$ is not a function (#9255)
This commit is contained in:
parent
fbcba24a9f
commit
0b4ea2ee67
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue