mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-24 21:34:24 +00:00
Remove docs and added them back? And also made the return uuid thing
now an endpoint that can be logged & cached.
This commit is contained in:
parent
5c64ae08bf
commit
0dfbdb4c91
21 changed files with 31 additions and 55 deletions
|
@ -1,34 +0,0 @@
|
|||
import { gunzip } from "zlib";
|
||||
import { promisify } from "util";
|
||||
|
||||
const gunzipAsync = promisify(gunzip);
|
||||
|
||||
// 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 buffer = await req.arrayBuffer();
|
||||
const decompressed = await gunzipAsync(Buffer.from(buffer));
|
||||
const res = JSON.parse(decompressed.toString());
|
||||
const data = res.getPageData?.[type];
|
||||
return res;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
async function demo() {
|
||||
console.log(await getLineTodayData("domestic"));
|
||||
}
|
||||
demo();
|
||||
|
||||
//export default getLineTodayData;
|
Loading…
Add table
Add a link
Reference in a new issue