|
|
|
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[26568],{93412:(e,t,r)=>{r.r(t),r.d(t,{assets:()=>c,contentTitle:()=>s,default:()=>h,frontMatter:()=>i,metadata:()=>u,toc:()=>p});var n=r(85893),a=r(11151),o=r(23277),l=r(64757);const i={hide_table_of_contents:!0},s="Puppeteer",u={id:"index",title:"Puppeteer",description:"build",source:"@site/../docs/index.md",sourceDirName:".",slug:"/",permalink:"/next/",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{hide_table_of_contents:!0}},c={},p=[{value:"Get started | API | FAQ | Contributing | Troubleshooting",id:"get-started--api--faq--contributing--troubleshooting",level:2},{value:"Installation",id:"installation",level:2},{value:"Example",id:"example",level:2}];function d(e){const t={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",img:"img",p:"p",pre:"pre",...(0,a.a)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(t.h1,{id:"puppeteer",children:"Puppeteer"}),"\n",(0,n.jsxs)(t.p,{children:[(0,n.jsx)(t.a,{href:"https://github.com/puppeteer/puppeteer/actions/workflows/ci.yml",children:(0,n.jsx)(t.img,{src:"https://github.com/puppeteer/puppeteer/actions/workflows/ci.yml/badge.svg?branch=main",alt:"build"})}),"\n",(0,n.jsx)(t.a,{href:"https://npmjs.org/package/puppeteer",children:(0,n.jsx)(t.img,{src:"https://img.shields.io/npm/v/puppeteer.svg",alt:"npm puppeteer package"})})]}),"\n",(0,n.jsx)("img",{src:"https://user-images.githubusercontent.com/10379601/29446482-04f7036a-841f-11e7-9872-91d1fc2ea683.png",height:"200",align:"right"}),"\n",(0,n.jsxs)(t.blockquote,{children:["\n",(0,n.jsxs)(t.p,{children:["Puppeteer is a Node.js library which provides a high-level API to control\nChrome or Firefox over the\n",(0,n.jsx)(t.a,{href:"https://chromedevtools.github.io/devtools-protocol/",children:"DevTools Protocol"})," or ",(0,n.jsx)(t.a,{href:"https://pptr.dev/webdriver-bidi",children:"WebDriver BiDi"}),'.\nPuppeteer runs in the headless (no visible UI) by default\nbut can be configured to run in a visible ("headful") browser.']}),"\n"]}),"\n",(0,n.jsxs)(t.h2,{id:"get-started--api--faq--contributing--troubleshooting",children:[(0,n.jsx)(t.a,{href:"https://pptr.dev/docs",children:"Get started"})," | ",(0,n.jsx)(t.a,{href:"https://pptr.dev/api",children:"API"})," | ",(0,n.jsx)(t.a,{href:"https://pptr.dev/faq",children:"FAQ"})," | ",(0,n.jsx)(t.a,{href:"https://pptr.dev/contributing",children:"Contributing"})," | ",(0,n.jsx)(t.a,{href:"https://pptr.dev/troubleshooting",children:"Troubleshooting"})]}),"\n",(0,n.jsx)(t.h2,{id:"installation",children:"Installation"}),"\n",(0,n.jsxs)(o.Z,{groupId:"npm2yarn",children:[(0,n.jsx)(l.Z,{value:"npm",children:(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-bash",children:"npm i puppeteer # Downloads compatible Chrome during installation.\nnpm i puppeteer-core # Alternatively, install as a library, without downloading Chrome.\n"})})}),(0,n.jsx)(l.Z,{value:"yarn",label:"Yarn",children:(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-bash",children:"yarn add puppeteer # Downloads compatible Chrome during installation.\nyarn add puppeteer-core # Alternatively, install as a library, without downloading Chrome.\n"})})}),(0,n.jsx)(l.Z,{value:"pnpm",label:"pnpm",children:(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-bash",children:"pnpm add puppeteer # Downloads compatible Chrome during installation.\npnpm add puppeteer-core # Alternatively, install as a library, without downloading Chrome.\n"})})})]}),"\n",(0,n.jsx)(t.h2,{id:"example",children:"Example"}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-ts",children:"import puppeteer from 'puppeteer'; // or import puppeteer from 'puppeteer-core';\n\n// Launch the browser and open a new blank page\nconst browser = await puppeteer.launch();\nconst page = await browser.newPage();\n\n// Navigate the page to a URL.\nawait page.goto('https://developer.chrome.com/');\n\n// Set screen size.\nawait page.setViewport({width: 1080, height: 1024});\n\n// Type into search box.\nawait page.
|