79 lines
2.8 KiB
Plaintext
79 lines
2.8 KiB
Plaintext
---
|
|
id: playwright-puppeteer-extra
|
|
title: Using puppeteer-extra and playwright-extra
|
|
---
|
|
|
|
import RunnableCodeBlock from '@site/src/components/RunnableCodeBlock';
|
|
import Tabs from '@theme/Tabs';
|
|
import TabItem from '@theme/TabItem';
|
|
import ApiLink from '@site/src/components/ApiLink';
|
|
import PuppeteerExtraSource from '!!raw-loader!roa-loader!./puppeteer-extra.ts';
|
|
import PlaywrightExtraSource from '!!raw-loader!roa-loader!./playwright-extra.ts';
|
|
|
|
[`puppeteer-extra`](https://www.npmjs.com/package/puppeteer-extra) and [`playwright-extra`](https://www.npmjs.com/package/playwright-extra) are community-built
|
|
libraries that bring in a plugin system to enhance the usage of [`puppeteer`](https://www.npmjs.com/package/puppeteer) and
|
|
[`playwright`](https://www.npmjs.com/package/playwright) respectively (bringing in extra functionality, like improving stealth for
|
|
example by using the Puppeteer Stealth plugin [(`puppeteer-extra-plugin-stealth`)](https://www.npmjs.com/package/puppeteer-extra-plugin-stealth)).
|
|
|
|
:::tip Available plugins
|
|
|
|
You can see a list of available plugins on the [`puppeteer-extra`s plugin list](https://www.npmjs.com/package/puppeteer-extra#plugins).
|
|
|
|
For [`playwright`](https://www.npmjs.com/package/playwright), please see [`playwright-extra`s plugin list](https://www.npmjs.com/package/playwright-extra#plugins) instead.
|
|
|
|
:::
|
|
|
|
In this example, we'll show you how to use the Puppeteer Stealth [(`puppeteer-extra-plugin-stealth`)](https://www.npmjs.com/package/puppeteer-extra-plugin-stealth) plugin
|
|
to help you avoid bot detections when crawling your target website.
|
|
|
|
<Tabs>
|
|
<TabItem value="puppeteer" label="Puppeteer & puppeteer-extra" default>
|
|
|
|
:::info Before you begin
|
|
|
|
Make sure you've installed the Puppeteer Extra (`puppeteer-extra`) and Puppeteer Stealth plugin(`puppeteer-extra-plugin-stealth`) packages via your preferred package manager
|
|
|
|
```bash
|
|
npm install puppeteer-extra puppeteer-extra-plugin-stealth
|
|
```
|
|
|
|
:::
|
|
|
|
:::tip
|
|
|
|
To run this example on the Apify Platform, select the `apify/actor-node-puppeteer-chrome` image for your Dockerfile.
|
|
|
|
:::
|
|
|
|
<RunnableCodeBlock className="language-js" title="src/crawler.ts" type="puppeteer">
|
|
{PuppeteerExtraSource}
|
|
</RunnableCodeBlock>
|
|
|
|
</TabItem>
|
|
|
|
<TabItem value="playwright" label="Playwright & playwright-extra">
|
|
|
|
:::info Before you begin
|
|
|
|
Make sure you've installed the `playwright-extra` and `puppeteer-extra-plugin-stealth` packages via your preferred package manager
|
|
|
|
```bash
|
|
npm install playwright-extra puppeteer-extra-plugin-stealth
|
|
```
|
|
|
|
:::
|
|
|
|
:::tip
|
|
|
|
To run this example on the Apify Platform, select the `apify/actor-node-puppeteer-chrome` image for your Dockerfile.
|
|
|
|
:::
|
|
|
|
<RunnableCodeBlock className="language-js" title="src/crawler.ts" type="playwright">
|
|
{PlaywrightExtraSource}
|
|
</RunnableCodeBlock>
|
|
|
|
</TabItem>
|
|
|
|
</Tabs>
|