mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 13:04:23 +00:00
Add docs :)
This commit is contained in:
parent
ba1b3afa6f
commit
7b46cc7e6f
41 changed files with 2405 additions and 16 deletions
|
@ -1,3 +1,8 @@
|
|||
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 {
|
||||
|
@ -10,7 +15,10 @@ async function getLineTodayData(type: string) {
|
|||
"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 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) {
|
||||
|
@ -18,6 +26,9 @@ async function getLineTodayData(type: string) {
|
|||
}
|
||||
}
|
||||
|
||||
console.log(await getLineTodayData("domestic"));
|
||||
async function demo() {
|
||||
console.log(await getLineTodayData("domestic"));
|
||||
}
|
||||
demo();
|
||||
|
||||
//export default getLineTodayData;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue