Files
job/scrape/main.ts
2026-04-26 16:33:33 +02:00

33 lines
653 B
TypeScript

const file_map = Bun.file("company.json");
const file_map_d = Bun.file("company_d.json");
let smap = "[]";
if(await file_map.exists())
smap = await file_map.text();
let smap_d = "[]";
if(await file_map_d.exists())
smap_d = await file_map_d.text();
let map = new Map<string, string>(JSON.parse(smap))
let map_d = new Map<string, number>(JSON.parse(smap_d));
for (const [name, url] of map) {
if(map_d.has(name)) continue;
const res = await Bun.$`./get_company.sh ${url}`.text();
console.log(res);
map_d.set(name, 1);
break;
}
let smap_e = JSON.stringify(Array.from(map_d.entries()), null, 2);
Bun.write("company_d.json", smap_e);