scraply 1.0.0 → 1.0.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/package.json +6 -3
- package/readme.md +4 -0
- package/src/scraply.js +10 -9
package/package.json
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scraply",
|
|
3
3
|
"description": "A simple, configurable and functional content scraper",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"main": "src/scraply.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"start": "node ."
|
|
9
9
|
},
|
|
10
|
-
"keywords": [
|
|
10
|
+
"keywords": [
|
|
11
|
+
"crawler",
|
|
12
|
+
"scraper"
|
|
13
|
+
],
|
|
11
14
|
"author": "Pau Serrat Gutiérrez",
|
|
12
15
|
"dependencies": {
|
|
13
16
|
"axios": "^1.7.7",
|
|
14
17
|
"cheerio": "^1.0.0",
|
|
15
18
|
"he": "^1.2.0"
|
|
16
19
|
}
|
|
17
|
-
}
|
|
20
|
+
}
|
package/readme.md
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
Scraply is a customizable and efficient web crawler and data scraper for Node.js, designed to handle various web crawling needs with ease. You can define the URLs to crawl, configure patterns to include/exclude, and format the output data in JSON. Scraply is built to be flexible, with user-configurable settings and dynamic paths.
|
|
2
|
+
|
|
3
|
+
Installation
|
|
4
|
+
`npm install scraply`
|
package/src/scraply.js
CHANGED
|
@@ -4,14 +4,9 @@ import { loadJSON, saveQueue, deleteDataFiles } from './utils/crawl/fileOperatio
|
|
|
4
4
|
import { processURL } from './utils/crawl/url/processor.js';
|
|
5
5
|
import { formatData, saveSortedFormattedJSON, saveHardcodedExtraLinks } from './utils/format/formatData.js';
|
|
6
6
|
|
|
7
|
-
const userConfig = {};
|
|
8
|
-
|
|
9
|
-
// Load and merge the configuration
|
|
10
|
-
const CONFIG = loadConfig(userConfig);
|
|
11
|
-
global.CONFIG = CONFIG;
|
|
12
|
-
|
|
13
7
|
let urlData = [];
|
|
14
8
|
let urlMetadata = {};
|
|
9
|
+
let CONFIG = {};
|
|
15
10
|
|
|
16
11
|
const initializeCrawler = () => {
|
|
17
12
|
urlData = loadJSON(CONFIG.CRAWLER.QUEUE_PATH);
|
|
@@ -44,7 +39,7 @@ const initializeCrawler = () => {
|
|
|
44
39
|
}
|
|
45
40
|
};
|
|
46
41
|
|
|
47
|
-
const
|
|
42
|
+
const crawler = async () => {
|
|
48
43
|
console.log(`STARTING CRAWLER
|
|
49
44
|
- Initial URLs: ${CONFIG.CRAWLER.INITIAL_URLS}
|
|
50
45
|
- Include URLs: ${CONFIG.CRAWLER.INCLUDE_URLS}
|
|
@@ -116,5 +111,11 @@ const app = async () => {
|
|
|
116
111
|
console.log(`Errors: ${errorData.length} -> ${CONFIG.DATA_FORMATTER.ERROR_REPORT_PATH}.`);
|
|
117
112
|
};
|
|
118
113
|
|
|
119
|
-
|
|
120
|
-
|
|
114
|
+
// Main function to be exported and used
|
|
115
|
+
export const scraply = async (userConfig = {}) => {
|
|
116
|
+
CONFIG = loadConfig(userConfig);
|
|
117
|
+
global.CONFIG = CONFIG;
|
|
118
|
+
|
|
119
|
+
initializeCrawler();
|
|
120
|
+
await crawler();
|
|
121
|
+
};
|