添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

When web scraping, we might want to collect page screenshots or peek into what our headless browsers are seeing for debugging. In Puppeteer a screenshot can be taken using the screenshot() method of page or element objects:

const puppeteer = require('puppeteer');
async function run() {
  // usual browser startup:
    const browser = await puppeteer.launch();
    const page = await browser.newPage();
    await page.goto("https://httpbin.dev/html");
    // wait for the selector appear on the page
    await page.screenshot({
      "type": "png", // can also be "jpeg" or "webp" (recommended)
      "path": "screenshot.png",  // where to save it
      "fullPage": true,  // will scroll down to capture everything if true
    // alternatively we can capture just a specific element:
    const element = await page.$("p");
    await element.screenshot({"path": "just-the-paragraph.png", "type": "png"});
    browser.close();
run();

⚠ Note that when scraping dynamic web pages, screenshots could be captured before the page is fully loaded. For more see How to wait for a page to load in Puppeteer?

Provided by Scrapfly

This knowledgebase is provided by Scrapfly — a web scraping API that allows you to scrape any website without getting blocked and implements a dozens of other web scraping conveniences. Check us out 👇 Try ScrapFly for FREE!
  • How to click on cookie popups and modal alerts in Puppeteer?
  • How to click on a pop up dialog in Puppeteer?
  • How to scroll to the bottom of the page with Puppeteer?
  • Getting started with Puppeteer Stealth
  • How to capture background requests and responses in Puppeteer?
  • How to load local files in Puppeteer?
  • How to save and load cookies in Puppeteer?
  • How to find elements by CSS selector in Puppeteer?
  • How to find elements by XPath in Puppeteer?
  • How to get page source in Puppeteer?
  • How to wait for a page to load in Puppeteer?
  • How to block resources in Puppeteer?
  • How to download a file with Puppeteer?
  • Web Scraping with NodeJS
  • Web Scraping with Python Scrapy
  • How to Scrape without getting blocked tutorial
  • Web Scraping with Python and BeautifulSoup
  • Web Scraping with Nodejs and Puppeteer
  • How To Scrape Graphql
  • Best Proxies for Web Scraping
  • Top 5 Best Residential Proxies
  • Web Scraping for Machine Learning
  • Web Scraping for News & Media
  • Web Scraping for Competitive Intelligence
  • Web Scraping for Business Automation
  •