diff --git a/lib/routes/wechat/sogou.ts b/lib/routes/wechat/sogou.ts index ded68525db..3940f6acab 100644 --- a/lib/routes/wechat/sogou.ts +++ b/lib/routes/wechat/sogou.ts @@ -14,7 +14,7 @@ interface SogouItemInternal extends DataItem { }; } -async function fetchAndParsePage(wechatId: string, page: number): Promise { +async function fetchAndParsePage(wechatId: string): Promise { const searchUrl = `${host}/weixin`; let response; try { @@ -26,17 +26,16 @@ async function fetchAndParsePage(wechatId: string, page: number): Promise a').text().trim(); const sogouLinkHref = $li.find('h3 > a').attr('href'); if (!sogouLinkHref) { - logger.warn(`Skipping item with missing link for wechatId: ${wechatId} on page ${page}`); + logger.warn(`Skipping item with missing link for wechatId: ${wechatId}`); return null; } const sogouLink = host + sogouLinkHref; @@ -61,10 +60,8 @@ async function fetchAndParsePage(wechatId: string, page: number): Promise[] = []; - for (let page = 1; page <= pageCount; page++) { - pagePromises.push(fetchAndParsePage(wechatId, page)); - } + const allItems: SogouItemInternal[] = await fetchAndParsePage(wechatId); - const pageResults: SogouItemInternal[][] = await Promise.all(pagePromises); - - const allItems: SogouItemInternal[] = pageResults.flat(); - - const firstPageFirstItem = pageResults[0]?.[0]; + const firstPageFirstItem = allItems[0]; const accountTitle = firstPageFirstItem?.author || wechatId; const finalItemsPromises = allItems.map(async (item: SogouItemInternal): Promise => {