fetchfox-sdk 1.0.17 → 1.0.18
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 +4 -4
- package/src/crawl.js +1 -1
- package/src/detach.js +2 -2
- package/src/extract.js +1 -1
- package/src/scrape.js +1 -1
- package/tests/fetchfox.test.js +19 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fetchfox-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"description": "AI scraper",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/fetchfox/fetchfox.git"
|
|
14
|
+
"url": "git+https://github.com/fetchfox/fetchfox-sdk.git"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
17
|
"ai",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"author": "marcell@fetchfoxai.com",
|
|
21
21
|
"license": "ISC",
|
|
22
22
|
"bugs": {
|
|
23
|
-
"url": "https://github.com/fetchfox/fetchfox/issues"
|
|
23
|
+
"url": "https://github.com/fetchfox/fetchfox-sdk/issues"
|
|
24
24
|
},
|
|
25
|
-
"homepage": "https://
|
|
25
|
+
"homepage": "https://fetchfox.ai",
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@eslint/js": "^9.31.0",
|
|
28
28
|
"eslint-plugin-promise": "^7.2.1",
|
package/src/crawl.js
CHANGED
package/src/detach.js
CHANGED
|
@@ -12,7 +12,7 @@ export const Job = class {
|
|
|
12
12
|
#callbacks;
|
|
13
13
|
#socket;
|
|
14
14
|
|
|
15
|
-
constructor(id) {
|
|
15
|
+
constructor(id, options) {
|
|
16
16
|
this.id = id;
|
|
17
17
|
this.#callbacks = {
|
|
18
18
|
completed: [],
|
|
@@ -21,7 +21,7 @@ export const Job = class {
|
|
|
21
21
|
progress: [],
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
this.#socket = new io(ws());
|
|
24
|
+
this.#socket = new io(ws(options));
|
|
25
25
|
this.#socket.on('progress', (data) => {
|
|
26
26
|
this.handleProgress(data);
|
|
27
27
|
});
|
package/src/extract.js
CHANGED
package/src/scrape.js
CHANGED
package/tests/fetchfox.test.js
CHANGED
|
@@ -32,6 +32,25 @@ test('use fetchfox object for detach @fetchfox @sanity', async () => {
|
|
|
32
32
|
expect(count).toBeGreaterThan(0);
|
|
33
33
|
}, 30_000);
|
|
34
34
|
|
|
35
|
+
test('use fetchfox object for extract detach @fetchfox @sanity', async () => {
|
|
36
|
+
const fox = new FetchFox({
|
|
37
|
+
apiKey: process.env.FETCHFOX_API_KEY,
|
|
38
|
+
});
|
|
39
|
+
const job = await fox.extract.detach({
|
|
40
|
+
urls: ['https://pokemondb.net/pokedex/bulbasaur'],
|
|
41
|
+
template: 'name and number',
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
let count = 0;
|
|
45
|
+
job.on('progress', (data) => {
|
|
46
|
+
count++;
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
await job.finished();
|
|
50
|
+
|
|
51
|
+
expect(count).toBeGreaterThan(0);
|
|
52
|
+
}, 30_000);
|
|
53
|
+
|
|
35
54
|
test('invalid key fails @fetchfox @sanity', async () => {
|
|
36
55
|
const fox = new FetchFox({
|
|
37
56
|
apiKey: 'invalid',
|