@spider-cloud/spider-client 0.0.2 → 0.0.6
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 +1 -0
- package/dist/spiderwebai.d.ts +7 -0
- package/dist/spiderwebai.js +11 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -67,6 +67,7 @@ app
|
|
|
67
67
|
- **`screenshot(url, params)`**: Take a screenshot of the specified URL.
|
|
68
68
|
- **`extractContacts(url, params)`**: Extract contact information from the specified URL.
|
|
69
69
|
- **`label(url, params)`**: Apply labeling to data extracted from the specified URL.
|
|
70
|
+
- **`getCrawlState(url, params)`**: Check the website crawl state.
|
|
70
71
|
- **`getCredits()`**: Retrieve account's remaining credits.
|
|
71
72
|
|
|
72
73
|
## Error Handling
|
package/dist/spiderwebai.d.ts
CHANGED
|
@@ -67,6 +67,13 @@ export default class Spider {
|
|
|
67
67
|
* @returns {Promise<any>} The labeled data.
|
|
68
68
|
*/
|
|
69
69
|
label(url: string, params?: {}): Promise<unknown>;
|
|
70
|
+
/**
|
|
71
|
+
* Check the crawl state of the website.
|
|
72
|
+
* @param {string} url - The URL to check.
|
|
73
|
+
* @param {object} [params={}] - Configuration parameters for crawl state. Can also pass in "domain" instead of the url to query.
|
|
74
|
+
* @returns {Promise<any>} The crawl state data.
|
|
75
|
+
*/
|
|
76
|
+
getCrawlState(url: string, params?: {}): Promise<unknown>;
|
|
70
77
|
/**
|
|
71
78
|
* Retrieves the number of credits available on the account.
|
|
72
79
|
* @returns {Promise<any>} The current credit balance.
|
package/dist/spiderwebai.js
CHANGED
|
@@ -24,7 +24,7 @@ class Spider {
|
|
|
24
24
|
*/
|
|
25
25
|
async _apiPost(endpoint, data, stream = false) {
|
|
26
26
|
const headers = this.prepareHeaders();
|
|
27
|
-
const response = await fetch(`https://
|
|
27
|
+
const response = await fetch(`https://spider.cloud/v1/${endpoint}`, {
|
|
28
28
|
method: "POST",
|
|
29
29
|
headers: headers,
|
|
30
30
|
body: JSON.stringify(data),
|
|
@@ -46,7 +46,7 @@ class Spider {
|
|
|
46
46
|
*/
|
|
47
47
|
async _apiGet(endpoint) {
|
|
48
48
|
const headers = this.prepareHeaders();
|
|
49
|
-
const response = await fetch(`https://
|
|
49
|
+
const response = await fetch(`https://spider.cloud/v1/${endpoint}`, {
|
|
50
50
|
method: "GET",
|
|
51
51
|
headers: headers,
|
|
52
52
|
});
|
|
@@ -112,6 +112,15 @@ class Spider {
|
|
|
112
112
|
async label(url, params = {}) {
|
|
113
113
|
return this._apiPost("pipeline/label", { url: url, ...params });
|
|
114
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Check the crawl state of the website.
|
|
117
|
+
* @param {string} url - The URL to check.
|
|
118
|
+
* @param {object} [params={}] - Configuration parameters for crawl state. Can also pass in "domain" instead of the url to query.
|
|
119
|
+
* @returns {Promise<any>} The crawl state data.
|
|
120
|
+
*/
|
|
121
|
+
async getCrawlState(url, params = {}) {
|
|
122
|
+
return this._apiPost("crawl-state", { url: url, ...params });
|
|
123
|
+
}
|
|
115
124
|
/**
|
|
116
125
|
* Retrieves the number of credits available on the account.
|
|
117
126
|
* @returns {Promise<any>} The current credit balance.
|