Make a poc for the api for line today & made some docs for myself and

others so others also can use the api
This commit is contained in:
yuanhau 2025-05-20 14:49:50 +08:00
parent 1680945186
commit ba1b3afa6f
12 changed files with 212 additions and 9 deletions

View file

@ -0,0 +1,23 @@
// Check /about/scraping_line_today_home.md for more info or https://news.yuanhau.com/datainfo/linetodayjsondata.json
async function getLineTodayData(type: string) {
try {
const buildUrl = `https://today.line.me/_next/data/v1/tw/v3/tab/${type}.json?tabs=${type}`;
const req = await fetch(buildUrl, {
headers: {
"Accept-Encoding": "gzip, deflate, br",
Accept: "application/json",
"User-Agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
},
});
const res = await req.json();
const data = res.getPageData?.[type];
return res;
} catch (e) {
console.log(e);
}
}
console.log(await getLineTodayData("domestic"));
//export default getLineTodayData;

35
server/fetchapi/run.txt Normal file
View file

@ -0,0 +1,35 @@
{
pageProps: {
__lang: "tw",
__namespaces: {
common: [Object ...],
forYou: [Object ...],
video: [Object ...],
quiz: [Object ...],
poll: [Object ...],
},
runtimeConfig: {
countryConfig: [Object ...],
COMMIT_SHA: "fb546888",
DEPLOY_ENV: "release",
SENTRY_DSN: "https://8ca685e4ca2f4b2ba32b4459381f91b8@sentry-uit.line-apps.com/475",
},
_sentryTraceData: "5c81d62ef22d861e5555ee0e170bd82b-a6d22f47579e751a-1",
_sentryBaggage: "sentry-environment=release,sentry-release=release%40fb546888,sentry-public_key=8ca685e4ca2f4b2ba32b4459381f91b8,sentry-trace_id=5c81d62ef22d861e5555ee0e170bd82b,sentry-transaction=getServerSideProps%20%2Fv3%2Ftab%2F%5B%5B...tabs%5D%5D,sentry-sampled=true",
articleDedupeState: {
pool: [Object ...],
serverPool: [Object ...],
},
fallback: {
getTabsData: [Object ...],
"getPageData,domestic": [Object ...],
"5e4ceeda408f3c5ca031940d_{\"offset\":5,\"length\":3}": [
[Object ...], [Object ...], [Object ...]
],
"5e4cee49408f3c5ca031940b_{\"offset\":0,\"length\":5}": [
[Object ...], [Object ...], [Object ...], [Object ...], [Object ...]
],
},
},
__N_SSP: true,
}