Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions components/screenshotbase/actions/capture/capture.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import screenshotbase from "../../screenshotbase.app.mjs";
import { axios } from "@pipedream/platform";

export default {
key: "screenshotbase-take",
name: "Take Screenshot",
description: "Render a website screenshot or PDF via Screenshotbase.",
version: "0.1.1",
type: "action",
props: {
screenshotbase,
url: {
label: "URL",
type: "string",
description: "Website to render",
optional: false,
},
width: {
type: "integer",
label: "Width",
optional: true,
default: 1280,
},
height: {
type: "integer",
label: "Height",
optional: true,
default: 800,
},
format: {
type: "string",
label: "Format",
description: "png | jpeg | pdf",
optional: true,
options: ["png", "jpeg", "pdf"],
},
fullPage: {
type: "boolean",
label: "Full Page",
optional: true,
},
waitForSelector: {
type: "string",
label: "Wait for CSS Selector",
optional: true,
},
omitBackground: {
type: "boolean",
label: "Transparent Background",
optional: true,
},
},
async run({ steps, $ }) {
const base = this.screenshotbase.baseUrl();
const params = {
url: this.url,
viewport_width: this.width,
viewport_height: this.height,
format: this.format,
full_page: this.fullPage ? 1 : undefined,
};
const res = await axios($, {
method: "GET",
url: `${base}/v1/take`,
headers: { apikey: this.screenshotbase.$auth.api_key },
params,
});
$.export("result", res);
return res;
},
};


40 changes: 40 additions & 0 deletions components/screenshotbase/actions/take_advanced/take_advanced.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import screenshotbase from "../../screenshotbase.app.mjs";
import { axios } from "@pipedream/platform";

export default {
key: "screenshotbase-take-advanced",
name: "Take Screenshot (Advanced)",
description: "Render a website with full set of parameters (format, quality, full_page, viewport)",
version: "0.1.0",
type: "action",
props: {
screenshotbase,
url: { label: "URL", type: "string", optional: false },
format: { label: "Format", type: "string", optional: true, options: ["jpg", "jpeg", "png", "gif"] },
quality: { label: "Quality (jpg/jpeg only)", type: "integer", optional: true },
full_page: { label: "Full Page", type: "boolean", optional: true },
viewport_width: { label: "Viewport Width", type: "integer", optional: true, default: 1280 },
viewport_height: { label: "Viewport Height", type: "integer", optional: true, default: 800 },
},
async run({ $ }) {
const base = this.screenshotbase.baseUrl();
const params = {
url: this.url,
format: this.format,
quality: this.quality,
full_page: this.full_page ? 1 : undefined,
viewport_width: this.viewport_width,
viewport_height: this.viewport_height,
};
const res = await axios($, {
method: "GET",
url: `${base}/v1/take`,
headers: { apikey: this.screenshotbase.$auth.api_key },
params,
});
$.export("result", res);
return res;
},
};


36 changes: 36 additions & 0 deletions components/screenshotbase/actions/take_html/take_html.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import screenshotbase from "../../screenshotbase.app.mjs";
import { axios } from "@pipedream/platform";

export default {
key: "screenshotbase-take-html",
name: "Take from HTML",
description: "Render a screenshot from raw HTML (served by Screenshotbase)",
version: "0.1.0",
type: "action",
props: {
screenshotbase,
html: { label: "HTML", type: "string", optional: false },
viewport_width: { label: "Viewport Width", type: "integer", optional: true, default: 800 },
viewport_height: { label: "Viewport Height", type: "integer", optional: true, default: 400 },
format: { label: "Format", type: "string", optional: true, options: ["jpg", "jpeg", "png", "gif"] },
},
async run({ $ }) {
const base = this.screenshotbase.baseUrl();
const params = {
html: this.html,
format: this.format,
viewport_width: this.viewport_width,
viewport_height: this.viewport_height,
};
const res = await axios($, {
method: "GET",
url: `${base}/v1/take`,
headers: { apikey: this.screenshotbase.$auth.api_key },
params,
});
$.export("result", res);
return res;
},
};


35 changes: 35 additions & 0 deletions components/screenshotbase/actions/take_pdf/take_pdf.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import screenshotbase from "../../screenshotbase.app.mjs";
import { axios } from "@pipedream/platform";

export default {
key: "screenshotbase-take-pdf",
name: "Take PDF",
description: "Render a PDF from a website URL",
version: "0.1.0",
type: "action",
props: {
screenshotbase,
url: { label: "URL", type: "string", optional: false },
viewport_width: { label: "Viewport Width", type: "integer", optional: true, default: 1280 },
viewport_height: { label: "Viewport Height", type: "integer", optional: true, default: 800 },
},
async run({ $ }) {
const base = this.screenshotbase.baseUrl();
const params = {
url: this.url,
format: "pdf",
viewport_width: this.viewport_width,
viewport_height: this.viewport_height,
};
const res = await axios($, {
method: "GET",
url: `${base}/v1/take`,
headers: { apikey: this.screenshotbase.$auth.api_key },
params,
});
$.export("result", res);
return res;
},
};


38 changes: 38 additions & 0 deletions components/screenshotbase/screenshotbase.app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
export default {
type: "app",
app: "screenshotbase",
name: "Screenshotbase",
propDefinitions: {},
auth: {
type: "custom",
fields: {
api_key: {
label: "API Key",
description: "Get your key from the Screenshotbase dashboard.",
type: "string",
},
base_url: {
label: "Base URL (optional)",
type: "string",
optional: true,
description: "Override API base, defaults to https://api.screenshotbase.com",
},
},
test: {
request: {
url: "https://api.screenshotbase.com/status",
headers: {
apikey: "{{auth.api_key}}",
},
},
},
connectionLabel: "Screenshotbase",
},
methods: {
baseUrl() {
return this.$auth.base_url?.trim() || "https://api.screenshotbase.com";
},
},
};