Skip to content

Commit 7178a84

Browse files
committed
NASAEARTH-17 switch land surface temp dataset
this one includes multiple years
1 parent 9a7e19c commit 7178a84

File tree

3 files changed

+4092
-2906
lines changed

3 files changed

+4092
-2906
lines changed

scripts/scrape-neo-images.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
// This can be run with `npx tsx scrape-neo-images.ts`
22
import * as cheerio from "cheerio";
33
import * as fs from "fs";
4-
import * as path from "path";
4+
import path, { dirname } from "path";
5+
import { fileURLToPath } from "url";
56
import { kNeoDatasetConfigs } from "../src/models/neo-dataset-configs.js";
67
import { NeoImageInfo, ScrapedNeoDatasetInfo, ScrapedNeoDatasetMap } from "../src/models/neo-types.js";
78

9+
const __filename = fileURLToPath(import.meta.url);
10+
const __dirname = dirname(__filename);
11+
812
async function fetchHtml(url: string): Promise<string> {
13+
// Delay to avoid overwhelming the server
14+
await new Promise(resolve => setTimeout(resolve, 500));
915
const response = await fetch(url);
1016
return await response.text();
1117
}
@@ -85,9 +91,9 @@ async function main() {
8591
// results.MOD_LSTD_CLIM_M = await processDataset("MOD_LSTD_CLIM_M");
8692

8793
// Make sure the data directory exists
88-
const dataDir = path.join(process.cwd(), "src", "data");
94+
const dataDir = path.join(__dirname, "..", "src", "data");
8995
if (!fs.existsSync(dataDir)) {
90-
fs.mkdirSync(dataDir);
96+
fs.mkdirSync(dataDir, { recursive: true });
9197
}
9298

9399
// Save results

0 commit comments

Comments
 (0)