← Puppeteer

Screenshot a Page with Puppeteer API

Pipedream makes it easy to connect APIs for Puppeteer and 2,000+ other apps remarkably fast.

Trigger workflow on
HTTP requests, schedules and app events
Next, do this
Screenshot a Page with the Puppeteer API
No credit card required
Intro to Pipedream
Watch us build a workflow
Watch us build a workflow
8 min
Watch now ➜

Trusted by 800,000+ developers from startups to Fortune 500 companies

Adyen logo
Appcues logo
Bandwidth logo
Checkr logo
ChartMogul logo
Dataminr logo
Gopuff logo
Gorgias logo
LinkedIn logo
Logitech logo
Replicated logo
Rudderstack logo
SAS logo
Scale AI logo
Webflow logo
Warner Bros. logo
Adyen logo
Appcues logo
Bandwidth logo
Checkr logo
ChartMogul logo
Dataminr logo
Gopuff logo
Gorgias logo
LinkedIn logo
Logitech logo
Replicated logo
Rudderstack logo
SAS logo
Scale AI logo
Webflow logo
Warner Bros. logo

Developers Pipedream

Getting Started

Create a workflow to Screenshot a Page with the Puppeteer API. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

  1. Configure the Screenshot a Page action
    1. Connect your Puppeteer account
    2. Configure URL
    3. Optional- Configure Download Path
    4. Optional- Configure Capture Beyond Viewport
    5. Optional- Configure Clip Height
    6. Optional- Configure Clip Scale
    7. Optional- Configure Clip Width
    8. Optional- Configure Clip X
    9. Optional- Configure Clip Y
    10. Optional- Select a Encoding
    11. Optional- Configure From Surface
    12. Optional- Configure Full Page
    13. Optional- Configure Omit Background
    14. Optional- Configure Optimize For Speed
    15. Optional- Configure Quality
    16. Optional- Select a Type
  2. Select a trigger to run your workflow on HTTP requests, schedules or app events
  3. Deploy the workflow
  4. Send a test event to validate your setup
  5. Turn on the trigger

Integrations

Screenshot a Page with Puppeteer API on New Requests (Payload Only) from HTTP / Webhook API
HTTP / Webhook + Puppeteer
 
Try it
Screenshot a Page with Puppeteer API on New Submission from Typeform API
Typeform + Puppeteer
 
Try it
Screenshot a Page with Puppeteer API on Custom Events from Zoom API
Zoom + Puppeteer
 
Try it
Screenshot a Page with Puppeteer API on New Submission (Instant) from Jotform API
Jotform + Puppeteer
 
Try it
Screenshot a Page with Puppeteer API on New Scheduled Tasks from Pipedream API
Pipedream + Puppeteer
 
Try it

Details

This is a pre-built, source-available component from Pipedream's GitHub repo. The component is developed by Pipedream and the community, and verified and maintained by Pipedream.

To contribute an update to an existing component or create a new component, create a PR on GitHub. If you're new to Pipedream component development, you can start with quickstarts for trigger span and action development, and then review the component API reference.

Screenshot a Page on Puppeteer
Description:Captures a screenshot of a page using Puppeteer. [See the documentation](https://pptr.dev/api/puppeteer.page.screenshot)
Version:1.0.1
Key:puppeteer-screenshot-page

Code

import puppeteer from "../../puppeteer.app.mjs";
import constants from "../../common/constants.mjs";
import fs from "fs";
import { ConfigurationError } from "@pipedream/platform";

export default {
  key: "puppeteer-screenshot-page",
  name: "Screenshot a Page",
  description: "Captures a screenshot of a page using Puppeteer. [See the documentation](https://pptr.dev/api/puppeteer.page.screenshot)",
  version: "1.0.1",
  type: "action",
  props: {
    puppeteer,
    url: {
      type: "string",
      label: "URL",
      description: "The URL of the page to scrape.",
    },
    downloadPath: {
      type: "string",
      label: "Download Path",
      description: "Download the screenshot to the `/tmp` directory with the specified filename",
      optional: true,
    },
    captureBeyondViewport: {
      type: "boolean",
      label: "Capture Beyond Viewport",
      description: "Capture the screenshot beyond the viewport.",
      optional: true,
      default: true,
    },
    clipHeight: {
      type: "string",
      label: "Clip Height",
      description: "Specifies the height of the region of the page to clip.",
      optional: true,
    },
    clipScale: {
      type: "string",
      label: "Clip Scale",
      description: "Specifies the scale of the region of the page to clip.",
      default: "1",
      optional: true,
    },
    clipWidth: {
      type: "string",
      label: "Clip Width",
      description: "Specifies the width of the region of the page to clip.",
      optional: true,
    },
    clipX: {
      type: "string",
      label: "Clip X",
      description: "Specifies the X value of the region of the page to clip.",
      optional: true,
    },
    clipY: {
      type: "string",
      label: "Clip Y",
      description: "Specifies Y value of the region of the page to clip.",
      optional: true,
    },
    encoding: {
      type: "string",
      label: "Encoding",
      description: "Encoding of the image.",
      optional: true,
      default: "binary",
      options: constants.IMAGE_ENCODING,
    },
    fromSurface: {
      type: "boolean",
      label: "From Surface",
      description: "Capture the screenshot from the surface, rather than the view.",
      optional: true,
      default: false,
    },
    fullPage: {
      type: "boolean",
      label: "Full Page",
      description: "When true, takes a screenshot of the full page.",
      optional: true,
      default: false,
    },
    omitBackground: {
      type: "boolean",
      label: "Omit Background",
      description: "Hides default white background and allows capturing screenshots with transparency.",
      optional: true,
      default: false,
    },
    optimizeForSpeed: {
      type: "boolean",
      label: "Optimize For Speed",
      description: "Optimize for speed.",
      optional: true,
      default: false,
    },
    quality: {
      type: "integer",
      label: "Quality",
      description: "Quality of the image, between 0-100. Not applicable to png images.",
      optional: true,
    },
    type: {
      type: "string",
      label: "Type",
      description: "Type of the screenshot image.",
      optional: true,
      default: "png",
      options: constants.SCREENSHOT_TYPE,
    },
  },
  methods: {
    async downloadToTMP(screenshot) {
      const path = this.downloadPath.includes("/tmp")
        ? this.downloadPath
        : `/tmp/${this.downloadPath}`;
      fs.writeFileSync(path, screenshot);
      return path;
    },
  },
  async run({ $ }) {
    if ((this.clipHeight || this.clipWidth || this.clipX || this.clipY)
      && !(this.clipHeight && this.clipWidth && this.clipX && this.clipY)) {
      throw new ConfigurationError("Clip height, width, X, and Y must be specified to create clip.");
    }

    const clip = this.clipHeight || this.clipWidth || this.clipX || this.clipY
      ? {
        height: parseFloat(this.clipHeight),
        scale: parseFloat(this.clipScale),
        width: parseFloat(this.clipWidth),
        x: parseFloat(this.clipX),
        y: parseFloat(this.clipY),
      }
      : undefined;

    const options = {
      captureBeyondViewport: this.captureBeyondViewport,
      clip,
      encoding: this.encoding,
      fromSurface: this.fromSurface,
      fullPage: this.fullPage,
      omitBackground: this.omitBackground,
      optimizeForSpeed: this.optimizeForSpeed,
      quality: this.quality,
      type: this.type,
    };

    const browser = await this.puppeteer.launch();
    const page = await browser.newPage();
    await page.goto(this.url);
    const screenshot = await page.screenshot(options);
    await browser.close();

    const filePath = screenshot && this.downloadPath
      ? await this.downloadToTMP(screenshot)
      : undefined;

    if (screenshot) {
      $.export("$summary", "Successfully captured screenshot from page.");
    }

    return filePath
      ? {
        screenshot: screenshot.toString("base64"),
        filePath,
      }
      : screenshot.toString("base64");
  },
};

Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI and CLI.
LabelPropTypeDescription
PuppeteerpuppeteerappThis component uses the Puppeteer app.
URLurlstring

The URL of the page to scrape.

Download PathdownloadPathstring

Download the screenshot to the /tmp directory with the specified filename

Capture Beyond ViewportcaptureBeyondViewportboolean

Capture the screenshot beyond the viewport.

Clip HeightclipHeightstring

Specifies the height of the region of the page to clip.

Clip ScaleclipScalestring

Specifies the scale of the region of the page to clip.

Clip WidthclipWidthstring

Specifies the width of the region of the page to clip.

Clip XclipXstring

Specifies the X value of the region of the page to clip.

Clip YclipYstring

Specifies Y value of the region of the page to clip.

EncodingencodingstringSelect a value from the drop down menu:base64binary
From SurfacefromSurfaceboolean

Capture the screenshot from the surface, rather than the view.

Full PagefullPageboolean

When true, takes a screenshot of the full page.

Omit BackgroundomitBackgroundboolean

Hides default white background and allows capturing screenshots with transparency.

Optimize For SpeedoptimizeForSpeedboolean

Optimize for speed.

Qualityqualityinteger

Quality of the image, between 0-100. Not applicable to png images.

TypetypestringSelect a value from the drop down menu:pngjpegwebp

Authentication

The Puppeteer API does not require authentication.

About Puppeteer

Puppeteer is a Node.js library which provides a high-level API to control Chrome/Chromium over the DevTools Protocol.

More Ways to Use Puppeteer

Actions

Get HTML with the Puppeteer API

Get the HTML of a webpage using Puppeteer. See the documentation

 
Try it
Get Page Title with the Puppeteer API

Get the title of a webpage using Puppeteer. See the documentation

 
Try it
Get PDF with the Puppeteer API

Generate a PDF of a page using Puppeteer. See the documentation

 
Try it

Explore Other Apps

1
-
24
of
2,000+
apps by most popular

HTTP / Webhook
HTTP / Webhook
Get a unique URL where you can send HTTP or webhook requests
Node
Node
Anything you can do with Node.js, you can do in a Pipedream workflow. This includes using most of npm's 400,000+ packages.
Python
Python
Anything you can do in Python can be done in a Pipedream Workflow. This includes using any of the 350,000+ PyPi packages available in your Python powered workflows.
OpenAI (ChatGPT)
OpenAI (ChatGPT)
OpenAI is an AI research and deployment company with the mission to ensure that artificial general intelligence benefits all of humanity. They are the makers of popular models like ChatGPT, DALL-E, and Whisper.
Premium
Salesforce (REST API)
Salesforce (REST API)
Web services API for interacting with Salesforce
Premium
HubSpot
HubSpot
HubSpot's CRM platform contains the marketing, sales, service, operations, and website-building software you need to grow your business.
Premium
Zoho CRM
Zoho CRM
Zoho CRM is an online Sales CRM software that manages your sales, marketing, and support in one CRM platform.
Premium
Stripe
Stripe
Stripe powers online and in-person payment processing and financial solutions for businesses of all sizes.
Shopify Developer App
Shopify Developer App
Shopify is a user-friendly e-commerce platform that helps small businesses build an online store and sell online through one streamlined dashboard.
Premium
WooCommerce
WooCommerce
WooCommerce is the open-source ecommerce platform for WordPress.
Premium
Snowflake
Snowflake
A data warehouse built for the cloud
Premium
MongoDB
MongoDB
MongoDB is an open source NoSQL database management program.
Supabase
Supabase
Supabase is an open source Firebase alternative.
MySQL
MySQL
MySQL is an open-source relational database management system.
PostgreSQL
PostgreSQL
PostgreSQL is a free and open-source relational database management system emphasizing extensibility and SQL compliance.
Premium
AWS
AWS
Amazon Web Services (AWS) offers reliable, scalable, and inexpensive cloud computing services.
Premium
Twilio SendGrid
Twilio SendGrid
Send marketing and transactional email through the Twilio SendGrid platform with the Email API, proprietary mail transfer agent, and infrastructure for scalable delivery.
Amazon SES
Amazon SES
Amazon SES is a cloud-based email service provider that can integrate into any application for high volume email automation
Premium
Klaviyo
Klaviyo
Email Marketing and SMS Marketing Platform
Premium
Zendesk
Zendesk
Zendesk is award-winning customer service software trusted by 200K+ customers. Make customers happy via text, mobile, phone, email, live chat, social media.
Premium
ServiceNow
ServiceNow
The smarter way to workflow
Notion
Notion
Notion is a new tool that blends your everyday work apps into one. It's the all-in-one workspace for you and your team.
Slack
Slack
Slack is a channel-based messaging platform. With Slack, people can work together more effectively, connect all their software tools and services, and find the information they need to do their best work — all within a secure, enterprise-grade environment.
Microsoft Teams
Microsoft Teams
Microsoft Teams has communities, events, chats, channels, meetings, storage, tasks, and calendars in one place.