From c41de8ee47e38ce5eba493c7c5bf6043201c38bb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 2 Aug 2022 13:33:57 +0000 Subject: [PATCH] style: auto format --- lib/v2/cmde/index.js | 57 +++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/lib/v2/cmde/index.js b/lib/v2/cmde/index.js index c45e32790..80db98d60 100644 --- a/lib/v2/cmde/index.js +++ b/lib/v2/cmde/index.js @@ -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) =>