@spider-cloud/spider-client 0.0.21 → 0.0.22

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 CHANGED
@@ -95,8 +95,10 @@ spider
95
95
 
96
96
  - **`scrapeUrl(url, params)`**: Scrape data from a specified URL. Optional parameters can be passed to customize the scraping behavior.
97
97
  - **`crawlUrl(url, params, stream)`**: Begin crawling from a specific URL with optional parameters for customization and an optional streaming response.
98
+ - **`search(q, params)`**: Perform a search and gather a list of websites to start crawling and collect resources.
98
99
  - **`links(url, params)`**: Retrieve all links from the specified URL with optional parameters.
99
100
  - **`screenshot(url, params)`**: Take a screenshot of the specified URL.
101
+ - **`transform(data, params)`**: Perform a fast HTML transformation to markdown or text.
100
102
  - **`extractContacts(url, params)`**: Extract contact information from the specified URL.
101
103
  - **`label(url, params)`**: Apply labeling to data extracted from the specified URL.
102
104
  - **`getCrawlState(url, params)`**: Check the website crawl state.
package/dist/client.d.ts CHANGED
@@ -64,6 +64,23 @@ export declare class Spider {
64
64
  * @returns {Promise<any>} The screenshot data.
65
65
  */
66
66
  screenshot(url: string, params?: {}): Promise<any>;
67
+ /**
68
+ * Perform a search and gather a list of websites to start crawling and collect resources.
69
+ * @param {string} search - The search query.
70
+ * @param {object} [params={}] - Configuration parameters for the search.
71
+ * @returns {Promise<any>} The result of the crawl, either structured data or a Response object if streaming.
72
+ */
73
+ search(q: string, params?: {}): Promise<any>;
74
+ /**
75
+ * Transform HTML to Markdown or text. You can send up to 10MB of data at once.
76
+ * @param {object} data - The data to trasnform, a list of objects with the key 'html' and optional 'url' key for readability.
77
+ * @param {object} [params={}] - Configuration parameters for the transformation.
78
+ * @returns {Promise<any>} The transformation result.
79
+ */
80
+ transform(data: {
81
+ html: string;
82
+ url?: string;
83
+ }[], params?: {}): Promise<any>;
67
84
  /**
68
85
  * Extracts contact information from the specified URL.
69
86
  * @param {string} url - The URL from which to extract contacts.
package/dist/client.js CHANGED
@@ -114,6 +114,24 @@ class Spider {
114
114
  async screenshot(url, params = {}) {
115
115
  return this._apiPost("screenshot", { url: url, ...params });
116
116
  }
117
+ /**
118
+ * Perform a search and gather a list of websites to start crawling and collect resources.
119
+ * @param {string} search - The search query.
120
+ * @param {object} [params={}] - Configuration parameters for the search.
121
+ * @returns {Promise<any>} The result of the crawl, either structured data or a Response object if streaming.
122
+ */
123
+ async search(q, params = {}) {
124
+ return this._apiPost("search", { search: q, ...params });
125
+ }
126
+ /**
127
+ * Transform HTML to Markdown or text. You can send up to 10MB of data at once.
128
+ * @param {object} data - The data to trasnform, a list of objects with the key 'html' and optional 'url' key for readability.
129
+ * @param {object} [params={}] - Configuration parameters for the transformation.
130
+ * @returns {Promise<any>} The transformation result.
131
+ */
132
+ async transform(data, params = {}) {
133
+ return this._apiPost("transform", { data, ...params });
134
+ }
117
135
  /**
118
136
  * Extracts contact information from the specified URL.
119
137
  * @param {string} url - The URL from which to extract contacts.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spider-cloud/spider-client",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "description": "A Javascript SDK for Spider Cloud services",
5
5
  "scripts": {
6
6
  "test": "jest",