From 6ee0d238924f2482bc353e18f456cec31110bb2f Mon Sep 17 00:00:00 2001 From: Felix Hsu Date: Wed, 28 Sep 2022 12:39:06 +0800 Subject: [PATCH] fix(route): ccdi cookie should be called in await style (#10927) * try to minic the js cookie behavior and bypass the anti spider * add more selector for diff article * regex polished * fix(route): cookie setting should be called in await --- lib/v2/gov/ccdi/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/v2/gov/ccdi/utils.js b/lib/v2/gov/ccdi/utils.js index caee722d5..1e23ec121 100644 --- a/lib/v2/gov/ccdi/utils.js +++ b/lib/v2/gov/ccdi/utils.js @@ -20,7 +20,7 @@ const parseCookie = async (body) => { const parseNewsList = async (url, selector, ctx) => { const response = await got(url, { cookieJar }); const data = response.data; - parseCookie(data); + await parseCookie(data); const $ = cheerio.load(data); const list = $(selector) @@ -44,7 +44,7 @@ const parseArticle = async (item, ctx) => await ctx.cache.tryGet(item.link, async () => { const response = await got(item.link, { cookieJar }); const data = response.data; - parseCookie(data); + await parseCookie(data); const $ = cheerio.load(data); const title = $('.daty, .source-box').text().trim();