@pipedream/spider 0.0.1 → 0.1.1
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.
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import spider from "../../spider.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "spider-scrape-new-page",
|
|
5
|
+
name: "Scrape New Page",
|
|
6
|
+
description: "Initiates a new page scrape (crawl). [See the documentation](https://spider.cloud/docs/api#crawl-website)",
|
|
7
|
+
version: "0.0.3",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: false,
|
|
12
|
+
},
|
|
13
|
+
type: "action",
|
|
14
|
+
ai: "optimized",
|
|
15
|
+
props: {
|
|
16
|
+
spider,
|
|
17
|
+
infoBox: {
|
|
18
|
+
type: "alert",
|
|
19
|
+
alertType: "info",
|
|
20
|
+
content: "See [the Spider documentation](https://spider.cloud/docs/api#crawl-website) for information on limits and best practices.",
|
|
21
|
+
},
|
|
22
|
+
url: {
|
|
23
|
+
type: "string",
|
|
24
|
+
label: "URL",
|
|
25
|
+
description: "The URI resource to crawl, e.g. `https://spider.cloud`. This can be a comma split list for multiple urls.",
|
|
26
|
+
},
|
|
27
|
+
limit: {
|
|
28
|
+
type: "integer",
|
|
29
|
+
label: "Limit",
|
|
30
|
+
description: "The maximum amount of pages allowed to crawl per website. Default is 0, which crawls all pages.",
|
|
31
|
+
optional: true,
|
|
32
|
+
},
|
|
33
|
+
storeData: {
|
|
34
|
+
type: "boolean",
|
|
35
|
+
label: "Store Data",
|
|
36
|
+
description: "Decide whether to store data. Default is `false`.",
|
|
37
|
+
optional: true,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
async run({ $ }) {
|
|
41
|
+
const content = await this.spider.initiateCrawl({
|
|
42
|
+
$,
|
|
43
|
+
data: {
|
|
44
|
+
url: this.url,
|
|
45
|
+
limit: this.limit,
|
|
46
|
+
store_data: this.storeData,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
$.export("$summary", `Successfully scraped URL ${this.url}`);
|
|
50
|
+
return content;
|
|
51
|
+
},
|
|
52
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/spider",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Pipedream Spider Components",
|
|
5
5
|
"main": "spider.app.mjs",
|
|
6
6
|
"keywords": [
|
|
@@ -11,5 +11,8 @@
|
|
|
11
11
|
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@pipedream/platform": "^3.1.1"
|
|
14
17
|
}
|
|
15
18
|
}
|
package/spider.app.mjs
CHANGED
|
@@ -1,11 +1,32 @@
|
|
|
1
|
+
import { axios } from "@pipedream/platform";
|
|
2
|
+
|
|
1
3
|
export default {
|
|
2
4
|
type: "app",
|
|
3
5
|
app: "spider",
|
|
4
6
|
propDefinitions: {},
|
|
5
7
|
methods: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
_baseUrl() {
|
|
9
|
+
return "https://api.spider.cloud";
|
|
10
|
+
},
|
|
11
|
+
async _makeRequest({
|
|
12
|
+
$ = this, path = "/", headers, ...otherOpts
|
|
13
|
+
} = {}) {
|
|
14
|
+
return axios($, {
|
|
15
|
+
...otherOpts,
|
|
16
|
+
url: this._baseUrl() + path,
|
|
17
|
+
headers: {
|
|
18
|
+
...headers,
|
|
19
|
+
"Authorization": `Bearer ${this.$auth.api_key}`,
|
|
20
|
+
"Content-Type": "application/json",
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
async initiateCrawl(args) {
|
|
25
|
+
return this._makeRequest({
|
|
26
|
+
method: "POST",
|
|
27
|
+
path: "/crawl",
|
|
28
|
+
...args,
|
|
29
|
+
});
|
|
9
30
|
},
|
|
10
31
|
},
|
|
11
|
-
};
|
|
32
|
+
};
|