From bb7ab3a088ba263336f9023762a068679c0fd909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B3=E5=85=83=E7=9A=93?= Date: Thu, 22 May 2025 18:13:55 +0800 Subject: [PATCH] Update more stuff, the shit fix is just rm -rf ing .nuxt .output --- about/scraping_line_today_home.md | 4 +--- server/api/home/uuid_lt/index.ts | 28 ++++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/about/scraping_line_today_home.md b/about/scraping_line_today_home.md index 46d8cbe..c90a0ef 100644 --- a/about/scraping_line_today_home.md +++ b/about/scraping_line_today_home.md @@ -4,10 +4,8 @@ This took me some time, but they use a fancy system for pulling news data. ## Endpoint on news.yuanhau.com aka this repo (Cached results) -### /api/home/uuid_lt/action?query=${query} -Fetches the uuid in each listings of the query -### /api/home/lt/${query} +### /api/home/uuid_lt/feed?query=${query} Fetches the uuid and returns back with the news ## Main endpoint diff --git a/server/api/home/uuid_lt/index.ts b/server/api/home/uuid_lt/index.ts index a88dec2..61ac197 100644 --- a/server/api/home/uuid_lt/index.ts +++ b/server/api/home/uuid_lt/index.ts @@ -71,6 +71,16 @@ async function tryToPullDataUUID(uuid: string) { "?country=tw&offset=0&length=27"; const req = await fetch(buildUrl); const res = await req.json(); + return res.items; +} + +async function tryToPullDataNUUID(link: string) { + const buildUrl = + "https://today.line.me/webapi/recommendation/hybrid/listings/" + + link + + "?country=tw&maxVideoCount=0&offset=0&length=70&optOut=false"; + const req = await fetch(buildUrl); + const res = await req.json(); return res; } @@ -91,7 +101,7 @@ export default defineEventHandler(async (event) => { const data = await tryToPullDataUUID(key); return data; }), - ); + ).then((ans) => ans.flat()); const diffFormat = []; data.forEach((key) => { if (validUUIDs.includes(key)) { @@ -101,10 +111,20 @@ export default defineEventHandler(async (event) => { } }); const fillll = filter2(diffFormat); + const cconaa: any[] = await Promise.all( + fillll.map(async (key) => { + if (key.includes("news_cat")) { + const data = await tryToPullDataNUUID(key); + return data; + } else { + } + }), + ).then((ans) => ans.flat()); return { - valid: uniqueUUIDs, - maybe: fillll, - returnData: returnData, + uuids: uniqueUUIDs, + nuuid: fillll, + uuidData: returnData, + nuuiddata: cconaa, }; } catch (e) { console.log(e);