mapcomplete/scripts/downloadLinkedDataList.ts

19 lines
731 B
TypeScript

import Script from "./Script"
import LinkedDataLoader from "../src/Logic/Web/LinkedDataLoader"
import { writeFileSync } from "fs"
class DownloadLinkedDataList extends Script {
constructor() {
super("Downloads the localBusinesses from the given location. Usage: url [--no-proxy]")
}
async main([url, noProxy]: string[]): Promise<void> {
const useProxy = noProxy !== "--no-proxy"
const data = await LinkedDataLoader.fetchJsonLd(url, {}, useProxy ? "proxy" : "fetch-lod")
const path = "linked_data_" + url.replace(/[^a-zA-Z0-9_]/g, "_") + ".jsonld"
writeFileSync(path, JSON.stringify(data), "utf8")
console.log("Written", path)
}
}
new DownloadLinkedDataList().run()