Skip to content

Commit 6a1c408

Browse files
committed
screenshot_fyi init
1 parent 306d2d8 commit 6a1c408

File tree

3 files changed

+160
-3
lines changed

3 files changed

+160
-3
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import screenshot_fyi from "../../screenshot_fyi.app.mjs";
2+
3+
export default {
4+
key: "screenshot_fyi-create-screenshot",
5+
name: "Create Screenshot",
6+
description: "Takes a screenshot of a webpage using Screenshot.fyi. [See the documentation](https://www.screenshot.fyi/api-docs)",
7+
version: "0.0.{{ts}}",
8+
type: "action",
9+
props: {
10+
screenshot_fyi: {
11+
type: "app",
12+
app: "screenshot_fyi",
13+
},
14+
url: {
15+
propDefinition: [
16+
screenshot_fyi,
17+
"url",
18+
],
19+
},
20+
width: {
21+
propDefinition: [
22+
screenshot_fyi,
23+
"width",
24+
],
25+
},
26+
height: {
27+
propDefinition: [
28+
screenshot_fyi,
29+
"height",
30+
],
31+
},
32+
fullpage: {
33+
propDefinition: [
34+
screenshot_fyi,
35+
"fullpage",
36+
],
37+
},
38+
format: {
39+
propDefinition: [
40+
screenshot_fyi,
41+
"format",
42+
],
43+
},
44+
disableCookieBanners: {
45+
propDefinition: [
46+
screenshot_fyi,
47+
"disableCookieBanners",
48+
],
49+
optional: true,
50+
},
51+
darkMode: {
52+
propDefinition: [
53+
screenshot_fyi,
54+
"darkMode",
55+
],
56+
optional: true,
57+
},
58+
},
59+
async run({ $ }) {
60+
const response = await this.screenshot_fyi.takeScreenshot();
61+
$.export("$summary", `Screenshot taken for ${this.url}`);
62+
return response;
63+
},
64+
};

components/screenshot_fyi/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"publishConfig": {
1313
"access": "public"
1414
}
15-
}
15+
}
Lines changed: 95 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,104 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "screenshot_fyi",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
url: {
8+
type: "string",
9+
label: "URL",
10+
description: "The URL of the webpage to capture",
11+
},
12+
width: {
13+
type: "integer",
14+
label: "Width",
15+
description: "The width of the screenshot",
16+
optional: true,
17+
},
18+
height: {
19+
type: "integer",
20+
label: "Height",
21+
description: "The height of the screenshot",
22+
optional: true,
23+
},
24+
fullpage: {
25+
type: "boolean",
26+
label: "Full Page",
27+
description: "Capture the full page of the webpage",
28+
optional: true,
29+
},
30+
format: {
31+
type: "string",
32+
label: "Format",
33+
description: "The format of the screenshot (e.g., png, jpeg)",
34+
optional: true,
35+
},
36+
disableCookieBanners: {
37+
type: "boolean",
38+
label: "Disable Cookie Banners",
39+
description: "Disable cookie banners in the screenshot",
40+
optional: true,
41+
},
42+
darkMode: {
43+
type: "boolean",
44+
label: "Dark Mode",
45+
description: "Enable dark mode in the screenshot",
46+
optional: true,
47+
},
48+
},
549
methods: {
6-
// this.$auth contains connected account data
750
authKeys() {
851
console.log(Object.keys(this.$auth));
952
},
53+
_baseUrl() {
54+
return "https://screenshot.fyi/api";
55+
},
56+
async _makeRequest(opts = {}) {
57+
const {
58+
$ = this,
59+
method = "GET",
60+
path = "/take",
61+
headers,
62+
params,
63+
...otherOpts
64+
} = opts;
65+
return axios($, {
66+
method,
67+
url: this._baseUrl() + path,
68+
headers: {
69+
...headers,
70+
Authorization: `Bearer ${this.$auth.api_key}`,
71+
},
72+
params,
73+
...otherOpts,
74+
});
75+
},
76+
async takeScreenshot() {
77+
const params = {
78+
url: this.url,
79+
...(this.width !== undefined && {
80+
width: this.width,
81+
}),
82+
...(this.height !== undefined && {
83+
height: this.height,
84+
}),
85+
...(this.fullpage !== undefined && {
86+
fullpage: this.fullpage,
87+
}),
88+
...(this.format && {
89+
format: this.format,
90+
}),
91+
...(this.disableCookieBanners !== undefined && {
92+
disableCookieBanners: this.disableCookieBanners,
93+
}),
94+
...(this.darkMode !== undefined && {
95+
darkMode: this.darkMode,
96+
}),
97+
};
98+
return this._makeRequest({
99+
params,
100+
});
101+
},
10102
},
103+
version: "0.0.{{ts}}",
11104
};

0 commit comments

Comments
 (0)