mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-24 21:34:24 +00:00
Commit broken code.
This commit is contained in:
parent
935a7f2737
commit
2d8628d0da
2 changed files with 15 additions and 0 deletions
|
@ -1,37 +0,0 @@
|
|||
// 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 req2 = res.pageProps.fallback["getPageData,domestic"].modules;
|
||||
const req3 = [];
|
||||
req2.forEach((key) => {
|
||||
const listings = key.listings;
|
||||
if (Array.isArray(listings)) {
|
||||
listings.forEach((listing) => {
|
||||
if (listing && listing.id) {
|
||||
req3.push(listing.id);
|
||||
}
|
||||
});
|
||||
} else if (listings && listings.id) {
|
||||
req3.push(listings.id);
|
||||
}
|
||||
});
|
||||
return req3;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const slug = getRouterParam(event, "slug");
|
||||
return await getLineTodayData(slug);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue