-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathharvest_ai_models.js
More file actions
45 lines (35 loc) · 1.18 KB
/
Copy pathharvest_ai_models.js
File metadata and controls
45 lines (35 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import fs from "fs";
import path from "path";
import dotenv from "dotenv";
import FirecrawlApp from "@mendable/firecrawl-js";
dotenv.config();
const cfg = {
sources: [
"https://huggingface.co/models",
"https://ollama.ai/library",
"https://openrouter.ai/models",
],
outDir: "outputs/ai_models",
};
const client = new FirecrawlApp({ apiKey: process.env.FIRECRAWL_API_KEY });
if (!fs.existsSync(cfg.outDir)) {
fs.mkdirSync(cfg.outDir, { recursive: true });
}
async function harvestModels() {
console.log("🌐 Starting model harvest...");
const timestamp = new Date().toISOString().split("T")[0];
for (const url of cfg.sources) {
try {
console.log(`🔎 Scraping ${url}...`);
const result = await client.scrapeUrl(url);
const cleanName = url.replace(/https?:\/\/|[^\w.-]/g, "_");
const outFile = path.join(cfg.outDir, `${cleanName}_${timestamp}.txt`);
fs.writeFileSync(outFile, result.text || result.content || "", "utf8");
console.log(`✅ Saved: ${outFile}`);
} catch (err) {
console.error(`❌ Error scraping ${url}:`, err.message);
}
}
console.log("✅ All model sources scraped successfully.");
}
harvestModels();