style: auto format

This commit is contained in:
github-actions[bot]
2022-08-02 13:33:57 +00:00
parent 85afee25fd
commit c41de8ee47
+27 -30
View File
@@ -8,38 +8,35 @@ module.exports = async (ctx) => {
const cate = ctx.params.cate ?? 'xwdt/zxyw';
const url = `${rootURL}/${cate}/`;
const browser = await require('@/utils/puppeteer')({ stealth: true });
const data = await ctx.cache.tryGet(
url,
async () => {
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', (request) => {
request.resourceType() === 'document' || request.resourceType() === 'script' ? request.continue() : request.abort();
});
await page.goto(url, {
waitUntil: 'domcontentloaded',
});
await page.waitForSelector('.list');
const html = await page.evaluate(() => document.documentElement.innerHTML);
await page.close();
const data = await ctx.cache.tryGet(url, async () => {
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', (request) => {
request.resourceType() === 'document' || request.resourceType() === 'script' ? request.continue() : request.abort();
});
await page.goto(url, {
waitUntil: 'domcontentloaded',
});
await page.waitForSelector('.list');
const html = await page.evaluate(() => document.documentElement.innerHTML);
await page.close();
const $ = cheerio.load(html);
const $ = cheerio.load(html);
return {
title: $('head title').text(),
description: $('meta[name=ColumnDescription]').attr('content'),
items: $('.list ul li')
.toArray()
.map((item) => {
item = $(item);
return {
title: $(item).find('a').attr('title'),
link: new URL($(item).find('a').attr('href'), url).href,
};
}),
};
},
);
return {
title: $('head title').text(),
description: $('meta[name=ColumnDescription]').attr('content'),
items: $('.list ul li')
.toArray()
.map((item) => {
item = $(item);
return {
title: $(item).find('a').attr('title'),
link: new URL($(item).find('a').attr('href'), url).href,
};
}),
};
});
const items = await Promise.all(
data.items.map((item) =>