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
This commit is contained in:
Felix Hsu 2022-09-28 12:39:06 +08:00 committed by GitHub
parent b0216ca3de
commit 6ee0d23892
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -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();