clean-web-scraper 3.2.0 → 3.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -7
- package/example-usage.js +3 -4
- package/package.json +1 -1
- package/src/WebScraper.js +2 -1
package/README.md
CHANGED
|
@@ -11,10 +11,10 @@ A powerful Node.js web scraper that extracts clean, readable content from websit
|
|
|
11
11
|
- 🚫 Excludes unwanted paths from scraping
|
|
12
12
|
- 🔄 Handles relative and absolute URLs like a pro
|
|
13
13
|
- 🎯 No duplicate page visits
|
|
14
|
-
-
|
|
15
|
-
- 📊 AI-friendly clean text and csv output (perfect for LLM fine-tuning!)
|
|
14
|
+
- 🤖 AI-friendly output formats (JSONL, CSV, clean text)
|
|
16
15
|
- 📊 Rich metadata extraction
|
|
17
16
|
- 📁 Combine results from multiple scrapers into a unified dataset
|
|
17
|
+
- 🎯 Turn any website into an AI training dataset
|
|
18
18
|
|
|
19
19
|
## 🛠️ Prerequisites
|
|
20
20
|
|
|
@@ -57,16 +57,38 @@ const scraper = new WebScraper({
|
|
|
57
57
|
includeMetadata: false, // Optional: Include metadata in output files
|
|
58
58
|
metadataFields: ['title', 'description'] // Optional: Specify metadata fields to include
|
|
59
59
|
});
|
|
60
|
-
scraper.start();
|
|
61
|
-
|
|
62
|
-
// Combine results from multiple scrapers
|
|
63
|
-
WebScraper.combineResults('./combined-dataset', [scraper1, scraper2]);
|
|
60
|
+
await scraper.start();
|
|
64
61
|
```
|
|
65
62
|
|
|
66
63
|
```bash
|
|
67
64
|
node example-usage.js
|
|
68
65
|
```
|
|
69
66
|
|
|
67
|
+
## 💻 Advanced Usage: Multi-Site Scraping
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
const WebScraper = require('clean-web-scraper');
|
|
71
|
+
|
|
72
|
+
// Scrape documentation website
|
|
73
|
+
const docsScraper = new WebScraper({
|
|
74
|
+
baseURL: 'https://docs.example.com',
|
|
75
|
+
scrapResultPath: './datasets/docs'
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Scrape blog website
|
|
79
|
+
const blogScraper = new WebScraper({
|
|
80
|
+
baseURL: 'https://blog.example.com',
|
|
81
|
+
scrapResultPath: './datasets/blog'
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// Start scraping both sites
|
|
85
|
+
await docsScraper.start();
|
|
86
|
+
await blogScraper.start();
|
|
87
|
+
|
|
88
|
+
// Combine all scraped content into a single dataset
|
|
89
|
+
await WebScraper.combineResults('./combined-dataset', [docsScraper, blogScraper]);
|
|
90
|
+
```
|
|
91
|
+
|
|
70
92
|
## 📤 Output
|
|
71
93
|
|
|
72
94
|
Your AI-ready content is saved in a clean, structured format:
|
|
@@ -100,7 +122,7 @@ example.com/
|
|
|
100
122
|
|
|
101
123
|
## 🤖 AI/LLM Training Ready
|
|
102
124
|
|
|
103
|
-
The output is specifically formatted for AI training purposes:
|
|
125
|
+
The output is specifically formatted for AI training and fine-tuning purposes:
|
|
104
126
|
|
|
105
127
|
- Clean, processed text without HTML markup
|
|
106
128
|
- Multiple formats (JSONL, CSV, text files)
|
package/example-usage.js
CHANGED
|
@@ -22,7 +22,7 @@ async function khameneiIrFreePalestineTag ()
|
|
|
22
22
|
includeMetadata: true,
|
|
23
23
|
metadataFields: ["title", "description", "author", "lastModified", "language"]
|
|
24
24
|
});
|
|
25
|
-
|
|
25
|
+
await scraper.start();
|
|
26
26
|
return scraper;
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -50,7 +50,7 @@ async function decolonizepalestine ()
|
|
|
50
50
|
includeMetadata: true,
|
|
51
51
|
metadataFields: ["title", "description", "author", "lastModified", "language"]
|
|
52
52
|
});
|
|
53
|
-
|
|
53
|
+
await scraper.start();
|
|
54
54
|
return scraper;
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -58,8 +58,7 @@ void async function main ()
|
|
|
58
58
|
{
|
|
59
59
|
const khameneiIrFreePalestineTagScraper = await khameneiIrFreePalestineTag();
|
|
60
60
|
const decolonizepalestineScraper = await decolonizepalestine();
|
|
61
|
-
await WebScraper.
|
|
62
|
-
WebScraper.combineResults( "./dataset/combined", [
|
|
61
|
+
await WebScraper.combineResults( "./dataset/combined", [
|
|
63
62
|
khameneiIrFreePalestineTagScraper,
|
|
64
63
|
decolonizepalestineScraper
|
|
65
64
|
] );
|
package/package.json
CHANGED
package/src/WebScraper.js
CHANGED
|
@@ -378,8 +378,9 @@ class WebScraper
|
|
|
378
378
|
return new Promise( resolve => { return setTimeout( resolve, ms ) });
|
|
379
379
|
}
|
|
380
380
|
|
|
381
|
-
static combineResults ( outputPath, websites )
|
|
381
|
+
static async combineResults ( outputPath, websites )
|
|
382
382
|
{
|
|
383
|
+
await WebScraper.sleep( 1000 );
|
|
383
384
|
const fullOutputPath = path.join( __dirname, outputPath );
|
|
384
385
|
|
|
385
386
|
// Create output directories
|