Skip to content

Commit 23a9a63

Browse files
committed
new component
1 parent d268b9a commit 23a9a63

File tree

4 files changed

+133
-5
lines changed

4 files changed

+133
-5
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import crawlbase from "../../crawlbase.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "crawlbase-crawl-url",
6+
name: "Crawl URL",
7+
description: "Crawl a URL. [See the documentation](https://crawlbase.com/docs/crawling-api/)",
8+
version: "0.0.1",
9+
type: "action",
10+
annotations: {
11+
destructiveHint: false,
12+
openWorldHint: true,
13+
readOnlyHint: false,
14+
},
15+
props: {
16+
crawlbase,
17+
url: {
18+
type: "string",
19+
label: "URL",
20+
description: "The URL to crawl",
21+
},
22+
scraper: {
23+
type: "string",
24+
label: "Scraper",
25+
description: "The scraper to use",
26+
options: constants.SCRAPERS,
27+
optional: true,
28+
},
29+
screenshot: {
30+
type: "boolean",
31+
label: "Screenshot",
32+
description: "Set to `true` to take a screenshot of the page. Must use a JavaScript token for authentication.",
33+
optional: true,
34+
},
35+
store: {
36+
type: "boolean",
37+
label: "Store",
38+
description: "Set to `true` to store a copy of the API response in the Crawlbase Cloud Storage",
39+
optional: true,
40+
},
41+
getHeaders: {
42+
type: "boolean",
43+
label: "Get Headers",
44+
description: "Set to `true` to get the headers of the page",
45+
optional: true,
46+
},
47+
},
48+
async run({ $ }) {
49+
const response = await this.crawlbase.makeRequest({
50+
$,
51+
params: {
52+
url: this.url,
53+
scraper: this.scraper,
54+
screenshot: this.screenshot,
55+
store: this.store,
56+
get_headers: this.getHeaders,
57+
format: "json",
58+
},
59+
});
60+
61+
$.export("$summary", `Successfully crawled URL: ${this.url}`);
62+
return response;
63+
},
64+
};
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
const SCRAPERS = [
2+
"amazon-product-details",
3+
"amazon-serp",
4+
"amazon-offer-listing",
5+
"amazon-best-sellers",
6+
"amazon-new-releases",
7+
"google-serp",
8+
"google-product-offers",
9+
"facebook-group",
10+
"facebook-page",
11+
"facebook-profile",
12+
"facebook-hashtag",
13+
"facebook-event",
14+
"instagram-reel",
15+
"instagram-post",
16+
"instagram-profile",
17+
"instagram-reels-audio",
18+
"tiktok-product",
19+
"tiktok-shop",
20+
"tiktok-profile",
21+
"shein-product",
22+
"linkedin-profile",
23+
"linkedin-company",
24+
"linkedin-feed",
25+
"quora-question",
26+
"airbnb-serp",
27+
"ebay-serp",
28+
"ebay-product",
29+
"ebay-seller-shop",
30+
"aliexpress-product",
31+
"aliexpress-serp",
32+
"bing-serp",
33+
"immobilienscout24-property",
34+
"walmart-serp",
35+
"walmart-product-details",
36+
"walmart-category",
37+
"bestbuy-serp",
38+
"bestbuy-product-details",
39+
"g2-product-reviews",
40+
"eventbrite-events-list",
41+
"eventbrite-event-details",
42+
"generic-extractor",
43+
"email-extractor",
44+
];
45+
46+
export default {
47+
SCRAPERS,
48+
};
Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "crawlbase",
46
propDefinitions: {},
57
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
8+
_baseUrl() {
9+
return "https://api.crawlbase.com";
10+
},
11+
makeRequest({
12+
$ = this, path = "", params = {}, ...opts
13+
}) {
14+
return axios($, {
15+
url: `${this._baseUrl()}${path}`,
16+
params: {
17+
...params,
18+
token: `${this.$auth.api_token}`,
19+
},
20+
...opts,
21+
});
922
},
1023
},
11-
};
24+
};

components/crawlbase/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/crawlbase",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Crawlbase Components",
55
"main": "crawlbase.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.1.0"
1417
}
1518
}

0 commit comments

Comments
 (0)