@spider-cloud/spider-client 0.1.27 → 0.1.29
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/dist/client.d.ts +5 -3
- package/dist/client.js +12 -5
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -59,10 +59,12 @@ export declare class Spider {
|
|
|
59
59
|
/**
|
|
60
60
|
* Retrieves all links from the specified URL.
|
|
61
61
|
* @param {string} url - The URL from which to gather links.
|
|
62
|
-
* @param {
|
|
63
|
-
* @
|
|
62
|
+
* @param {GenericParams} [params={}] - Additional parameters for the crawl.
|
|
63
|
+
* @param {boolean} [stream=false] - Whether to receive the response as a stream.
|
|
64
|
+
* @param {function} [callback=function] - The callback function when streaming per chunk. If this is set with stream you will not get a end response.
|
|
65
|
+
* @returns {Promise<any | Response>} The result of the crawl, either structured data or a Response object if streaming.
|
|
64
66
|
*/
|
|
65
|
-
links(url: string, params?:
|
|
67
|
+
links(url: string, params?: GenericParams, stream?: boolean, cb?: ChunkCallbackFunction): Promise<SpiderCoreResponse[] | void>;
|
|
66
68
|
/**
|
|
67
69
|
* Takes a screenshot of the website starting from this URL.
|
|
68
70
|
* @param {string} url - The URL to start the screenshot.
|
package/dist/client.js
CHANGED
|
@@ -106,7 +106,7 @@ class Spider {
|
|
|
106
106
|
*/
|
|
107
107
|
async crawlUrl(url, params = {}, stream = false, cb) {
|
|
108
108
|
const jsonl = stream && cb;
|
|
109
|
-
const res = await this._apiPost(config_1.APIRoutes.Crawl, { url
|
|
109
|
+
const res = await this._apiPost(config_1.APIRoutes.Crawl, { url, ...params }, stream, !!jsonl);
|
|
110
110
|
if (jsonl) {
|
|
111
111
|
return await (0, stream_reader_1.streamReader)(res, cb);
|
|
112
112
|
}
|
|
@@ -115,11 +115,18 @@ class Spider {
|
|
|
115
115
|
/**
|
|
116
116
|
* Retrieves all links from the specified URL.
|
|
117
117
|
* @param {string} url - The URL from which to gather links.
|
|
118
|
-
* @param {
|
|
119
|
-
* @
|
|
118
|
+
* @param {GenericParams} [params={}] - Additional parameters for the crawl.
|
|
119
|
+
* @param {boolean} [stream=false] - Whether to receive the response as a stream.
|
|
120
|
+
* @param {function} [callback=function] - The callback function when streaming per chunk. If this is set with stream you will not get a end response.
|
|
121
|
+
* @returns {Promise<any | Response>} The result of the crawl, either structured data or a Response object if streaming.
|
|
120
122
|
*/
|
|
121
|
-
async links(url, params = {}) {
|
|
122
|
-
|
|
123
|
+
async links(url, params = {}, stream = false, cb) {
|
|
124
|
+
const jsonl = stream && cb;
|
|
125
|
+
const res = await this._apiPost(config_1.APIRoutes.Links, { url, ...params }, stream, !!jsonl);
|
|
126
|
+
if (jsonl) {
|
|
127
|
+
return await (0, stream_reader_1.streamReader)(res, cb);
|
|
128
|
+
}
|
|
129
|
+
return res;
|
|
123
130
|
}
|
|
124
131
|
/**
|
|
125
132
|
* Takes a screenshot of the website starting from this URL.
|