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 04:39:06 +00:00
committed by GitHub
parent b0216ca3de
commit 6ee0d23892
+2 -2
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();