import { KEYWORDS } from "../config.ts"; import { fetchJobs, isEnglishContent } from "../fetch.ts"; import { readFileSync } from "fs"; // Load existing IDs from CSV const csv = readFileSync("./results/jobs.csv", "utf8"); const existingIds = new Set( [...csv.matchAll(/jobs\/view\/(\d+)\//g)].map((m) => m[1]) ); const jobs = await fetchJobs({ label: "CH Remote", keywords: KEYWORDS, location: "Switzerland", workType: ["remote"], timePosted: "month", }); const newJobs = jobs.filter((j) => !existingIds.has(j.id)); console.log(`\n${newJobs.length} new remote CH jobs. Checking English content…\n`); const results = []; for (const j of newJobs) { process.stdout.write(` ${j.title} … `); const ok = await isEnglishContent(j.id); console.log(ok ? "ok" : "dropped (non-English)"); if (ok) results.push(j); } console.log(`\n${results.length} vagas remotas novas na Suíça\n`); for (const j of results) { console.log(`${j.title} — ${j.company}`); console.log(` ${j.link}`); }