<ahref="https://npmjs.org/package/puppeteer"target="_blank"rel="noopener noreferrer"><imgloading="lazy"src="https://img.shields.io/npm/v/puppeteer.svg"alt="npm puppeteer package"class="img_ev3q"></a></p><imgloading="lazy"src="https://user-images.githubusercontent.com/10379601/29446482-04f7036a-841f-11e7-9872-91d1fc2ea683.png"height="200"align="right"class="img_ev3q"><h4class="anchor anchorWithStickyNavbar_LWe7"id="api--faq--contributing--troubleshooting"><ahref="https://pptr.dev/api"target="_blank"rel="noopener noreferrer">API</a> | <ahref="https://pptr.dev/faq"target="_blank"rel="noopener noreferrer">FAQ</a> | <ahref="https://pptr.dev/contributing"target="_blank"rel="noopener noreferrer">Contributing</a> | <ahref="https://pptr.dev/troubleshooting"target="_blank"rel="noopener noreferrer">Troubleshooting</a><aclass="hash-link"href="#api--faq--contributing--troubleshooting"title="Direct link to heading"></a></h4><blockquote><p>Puppeteer is a Node.js library which provides a high-level API to control
mode by default, but can be configured to run in full (non-headless)
Chrome/Chromium.</p></blockquote><h4class="anchor anchorWithStickyNavbar_LWe7"id="what-can-i-do">What can I do?<aclass="hash-link"href="#what-can-i-do"title="Direct link to heading"></a></h4><p>Most things that you can do manually in the browser can be done using Puppeteer!
Here are a few examples to get you started:</p><ul><li>Generate screenshots and PDFs of pages.</li><li>Crawl a SPA (Single-Page Application) and generate pre-rendered content (i.e.
"SSR" (Server-Side Rendering)).</li><li>Automate form submission, UI testing, keyboard input, etc.</li><li>Create an automated testing environment using the latest JavaScript and
of your site to help diagnose performance issues.</li><li>Test Chrome Extensions.</li></ul><h2class="anchor anchorWithStickyNavbar_LWe7"id="getting-started">Getting Started<aclass="hash-link"href="#getting-started"title="Direct link to heading"></a></h2><h3class="anchor anchorWithStickyNavbar_LWe7"id="installation">Installation<aclass="hash-link"href="#installation"title="Direct link to heading"></a></h3><p>To use Puppeteer in your project, run:</p><divclass="language-bash codeBlockContainer_Ckt0 theme-code-block"style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><divclass="codeBlockContent_biex"><pretabindex="0"class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><codeclass="codeBlockLines_e6Vv"><spanclass="token-line"style="color:#393A34"><spanclass="token function"style="color:#d73a49">npm</span><spanclass="token plain"> i puppeteer</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"></span><spanclass="token comment"style="color:#999988;font-style:italic"># or `yarn add puppeteer`</span><spanclass="token plain"></span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"></span><spanclass="token comment"style="color:#999988;font-style:italic"># or `pnpm i puppeteer`</span><br></span></code></pre><divclass="buttonGroup__atx"><buttontype="button"aria-label="Copy code to clipboard"title="Copy"class="clean-btn"><spanclass="copyButtonIcons_eSgA"aria-hidden="true"><svgclass="copyButtonIcon_y97N"viewBox="0 0 24 24"><pathd="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svgclass="copyButtonSuccessIcon_LjdS"viewBox="0 0 24 24"><pathd="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>When you install Puppeteer, it automatically downloads a recent version of
Chromium (~170MB macOS, ~282MB Linux, ~280MB Windows) that is
<ahref="https://pptr.dev/faq#q-why-doesnt-puppeteer-vxxx-work-with-chromium-vyyy"target="_blank"rel="noopener noreferrer">guaranteed to work</a>
with Puppeteer. For a version of Puppeteer without installation, see
<ahref="#puppeteer-core"><code>puppeteer-core</code></a>.</p><h4class="anchor anchorWithStickyNavbar_LWe7"id="environment-variables">Environment Variables<aclass="hash-link"href="#environment-variables"title="Direct link to heading"></a></h4><p>Puppeteer looks for certain
<ahref="https://en.wikipedia.org/wiki/Environment_variable"target="_blank"rel="noopener noreferrer">environment variables</a> for
customizing behavior. If Puppeteer doesn't find them in the environment during
the installation step, a lowercased variant of these variables will be used from
the <ahref="https://docs.npmjs.com/cli/config"target="_blank"rel="noopener noreferrer">npm config</a>.</p><ul><li><code>HTTP_PROXY</code>, <code>HTTPS_PROXY</code>, <code>NO_PROXY</code> - defines HTTP proxy settings that are
used to download and run the browser.</li><li><code>PUPPETEER_CACHE_DIR</code> - defines the directory to be used by Puppeteer for
caching. Defaults to
<ahref="https://nodejs.org/api/os.html#os_os_homedir"target="_blank"rel="noopener noreferrer"><code>os.homedir()/.cache/puppeteer</code></a>.</li><li><code>PUPPETEER_SKIP_CHROMIUM_DOWNLOAD</code> - do not download bundled Chromium during
installation step.</li><li><code>PUPPETEER_TMP_DIR</code> - defines the directory to be used by Puppeteer for
creating temporary files. Defaults to
<ahref="https://nodejs.org/api/os.html#os_os_tmpdir"target="_blank"rel="noopener noreferrer"><code>os.tmpdir()</code></a>.</li><li><code>PUPPETEER_DOWNLOAD_HOST</code> - specifies the URL prefix that is used to download
Chromium. Note: this includes protocol and might even include path prefix.
Defaults to <code>https://storage.googleapis.com</code>.</li><li><code>PUPPETEER_DOWNLOAD_PATH</code> - specifies the path for the downloads folder.
Defaults to <code><cache>/chromium</code>, where <code><cache></code> is Puppeteer's cache
directory.</li><li><code>PUPPETEER_BROWSER_REVISION</code> - specifies a certain version of the browser
you'd like Puppeteer to use. See
<ahref="https://pptr.dev/api/puppeteer.puppeteernode.launch"target="_blank"rel="noopener noreferrer"><code>puppeteer.launch</code></a> on
how executable path is inferred.</li><li><code>PUPPETEER_EXECUTABLE_PATH</code> - specifies an executable path to be used in
<ahref="https://pptr.dev/api/puppeteer.puppeteernode.launch"target="_blank"rel="noopener noreferrer"><code>puppeteer.launch</code></a>.</li><li><code>PUPPETEER_PRODUCT</code> - specifies which browser you'd like Puppeteer to use.
Must be either <code>chrome</code> or <code>firefox</code>. This can also be used during
installation to fetch the recommended browser binary. Setting <code>product</code>
supersedes this environment variable.</li><li><code>PUPPETEER_EXPERIMENTAL_CHROMIUM_MAC_ARM</code> — specify Puppeteer download
Chromium for Apple M1. On Apple M1 devices Puppeteer by default downloads the
version for Intel's processor which runs via Rosetta. It works without any
problems, however, with this option, you should get more efficient resource
usage (CPU and RAM) that could lead to a faster execution time.</li></ul><p>Environment variables except for <code>PUPPETEER_CACHE_DIR</code> are not used for
<ahref="#puppeteer-core"><code>puppeteer-core</code></a> since core does not automatically handle
browser downloading.</p><h4class="anchor anchorWithStickyNavbar_LWe7"id="puppeteer-core"><code>puppeteer-core</code><aclass="hash-link"href="#puppeteer-core"title="Direct link to heading"></a></h4><p>Every release since v1.7.0 we publish two packages:</p><ul><li><ahref="https://www.npmjs.com/package/puppeteer"target="_blank"rel="noopener noreferrer"><code>puppeteer</code></a></li><li><ahref="https://www.npmjs.com/package/puppeteer-core"target="_blank"rel="noopener noreferrer"><code>puppeteer-core</code></a></li></ul><p><code>puppeteer</code> is a <em>product</em> for browser automation. When installed, it downloads
a version of Chromium, which it then drives using <code>puppeteer-core</code>. Being an
end-user product, <code>puppeteer</code> supports a bunch of convenient <code>PUPPETEER_*</code> env
variables to tweak its behavior.</p><p><code>puppeteer-core</code> is a <em>library</em> to help drive anything that supports DevTools
protocol. <code>puppeteer-core</code> doesn't download Chromium when installed. Being a
library, <code>puppeteer-core</code> is fully driven through its programmatic interface.</p><p>You should only use <code>puppeteer-core</code> if you are
<ahref="https://pptr.dev/api/puppeteer.puppeteer.connect"target="_blank"rel="noopener noreferrer">connecting to a remote browser</a>
or <ahref="https://pptr.dev/api/puppeteer.browserfetcher"target="_blank"rel="noopener noreferrer">managing browsers yourself</a>.
If you are managing browsers yourself, you will need to call
<ahref="https://pptr.dev/api/puppeteer.puppeteernode.launch"target="_blank"rel="noopener noreferrer"><code>puppeteer.launch</code></a> with
a <ahref="https://pptr.dev/api/puppeteer.browser"target="_blank"rel="noopener noreferrer">browser</a>,
<ahref="https://pptr.dev/api/puppeteer.browser.newpage"target="_blank"rel="noopener noreferrer">create</a> some
<ahref="https://pptr.dev/api/puppeteer.page"target="_blank"rel="noopener noreferrer">pages</a>, and then manipulate them with
<ahref="https://pptr.dev/api"target="_blank"rel="noopener noreferrer">Puppeteer's API</a>.</p><p>For more in-depth usage, check our <ahref="https://pptr.dev/guides"target="_blank"rel="noopener noreferrer">guides</a> and
<ahref="https://github.com/puppeteer/puppeteer/tree/main/examples"target="_blank"rel="noopener noreferrer">examples</a>.</p><h4class="anchor anchorWithStickyNavbar_LWe7"id="example">Example<aclass="hash-link"href="#example"title="Direct link to heading"></a></h4><p>The following example searches
<ahref="https://developers.google.com/web"target="_blank"rel="noopener noreferrer">developers.google.com/web</a> for articles
describes some differences for Linux users.</p><p><strong>3. Creates a fresh user profile</strong></p><p>Puppeteer creates its own browser user profile which it <strong>cleans up on every
run</strong>.</p><h4class="anchor anchorWithStickyNavbar_LWe7"id="using-docker">Using Docker<aclass="hash-link"href="#using-docker"title="Direct link to heading"></a></h4><p>See our <ahref="https://pptr.dev/guides/docker"target="_blank"rel="noopener noreferrer">guide on using Docker</a>.</p><h4class="anchor anchorWithStickyNavbar_LWe7"id="using-chrome-extensions">Using Chrome Extensions<aclass="hash-link"href="#using-chrome-extensions"title="Direct link to heading"></a></h4><p>See our
<ahref="https://pptr.dev/guides/chrome-extensions"target="_blank"rel="noopener noreferrer">guide on using Chrome extensions</a>.</p><h2class="anchor anchorWithStickyNavbar_LWe7"id="resources">Resources<aclass="hash-link"href="#resources"title="Direct link to heading"></a></h2><ul><li><ahref="https://pptr.dev/api"target="_blank"rel="noopener noreferrer">API Documentation</a></li><li><ahref="https://pptr.dev/guides"target="_blank"rel="noopener noreferrer">Guides</a></li><li><ahref="https://github.com/puppeteer/puppeteer/tree/main/examples"target="_blank"rel="noopener noreferrer">Examples</a></li><li><ahref="https://github.com/transitive-bullshit/awesome-puppeteer"target="_blank"rel="noopener noreferrer">Community list of Puppeteer resources</a></li></ul><h2class="anchor anchorWithStickyNavbar_LWe7"id="contributing">Contributing<aclass="hash-link"href="#contributing"title="Direct link to heading"></a></h2><p>Check out our <ahref="https://pptr.dev/contributing"target="_blank"rel="noopener noreferrer">contributing guide</a> to get an
overview of Puppeteer development.</p><h2class="anchor anchorWithStickyNavbar_LWe7"id="faq">FAQ<aclass="hash-link"href="#faq"title="Direct link to heading"></a></h2><p>Our <ahref="https://pptr.dev/faq"target="_blank"rel="noopener noreferrer">FAQ</a> has migrated to