mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 13:04:23 +00:00
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:
parent
1680945186
commit
ba1b3afa6f
12 changed files with 212 additions and 9 deletions
23
server/fetchapi/lt_home.ts
Normal file
23
server/fetchapi/lt_home.ts
Normal 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;
|
Loading…
Add table
Add a link
Reference in a new issue