# pwpr

> A small CLI utility wrapper around playwright to make it easy to prerender a javascript rendered webpage

Latest version **4.2.2** (published 2022-12-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install pwpr
pnpm add pwpr
yarn add pwpr
bun add pwpr
```

Provides the command `pwpr`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.2.2 |
| Published | 2022-12-14 |
| First published | 2021-08-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=18 |
| Dependencies | 4 |
| Unpacked size | 11.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Andrew Brey |
| Maintainers | andrewbrey |
| Keywords | cli, html, playwright, prerender, puppeteer, render |

## Links

- npm: https://www.npmjs.com/package/pwpr
- Repository: https://github.com/andrewbrey/pwpr
- Issues: https://github.com/andrewbrey/pwpr/issues
- npm.io page: https://npm.io/package/pwpr

## Dependencies (4)

- [chalk](https://npm.io/package/chalk.md) 5.2.0
- [fs-extra](https://npm.io/package/fs-extra.md) 11.1.0
- [minimist](https://npm.io/package/minimist.md) 1.2.7
- [playwright](https://npm.io/package/playwright.md) 1.28.1

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 4.2.2 (latest) — 2022-12-14
- 4.2.1 — 2022-12-12
- 4.0.0 — 2022-12-12
- 3.3.1 — 2022-06-23
- 3.3.0 — 2022-06-23
- 3.2.0 — 2022-06-21
- 3.1.0 — 2022-04-03
- 2.2.0 — 2021-08-16
- 2.1.0 — 2021-08-04
- 2.0.2 — 2021-08-04
- 2.0.1 — 2021-08-04
- 2.0.0 — 2021-08-04
- 1.1.0 — 2021-08-03

## README

# PWPR (**P**lay**w**right **P**re-**R**ender)

A small utility wrapper around playwright [https://playwright.dev] which makes it simple
to fetch, prerender, and return the html contents of javascript rendered pages.

[![Version](https://img.shields.io/npm/v/pwpr.svg)](https://npmjs.org/package/pwpr)
[![Downloads/week](https://img.shields.io/npm/dw/pwpr.svg)](https://npmjs.org/package/pwpr)
[![License](https://img.shields.io/npm/l/pwpr.svg)](https://github.com/andrewbrey/pwpr/blob/master/package.json)

**USAGE**

```bash
$ npx pwpr <options>
```

**OPTIONS**

```
-h, --help    show CLI help
--url         [required] the url to visit and prerender
              (if either http or https protocol not specified, https will be assumed)

--output      a valid file path into which the page content should be saved
              (if omitted, page content will print to stdout; if present and lacking a
              file extension, .html will be assumed)

--load        the timeout in milliseconds to wait for the page to load (default 30000)
--js          the timeout in milliseconds to wait for JS execution (default 5000)
              (only used if option --selector is provided)

--selector    the css selector to wait for before capturing the page
--sleep       the timeout in milliseconds to wait before capturing the page (default 1000)
              (only used if option --selector is omitted)

--ua          if provided will set the browser user agent
              (default value is auto-generated by playwright and is platform dependent)

--locale      if provided will set the browser locale, defaults to en-US

--show        if provided will cause the browser to be shown (default false)
--debug       enable debug output (default false)
```

**EXAMPLES**

```bash
npx pwpr --url=http://example.com
# prerenders http://example.com and prints to stdout

npx pwpr --url=example.com
# prerenders https://example.com and prints to stdout

npx pwpr --url=example.com --load=60000
# prerenders https://example.com after allowing *up to* 60 seconds for the
# document to fire the "load" event, and prints to stdout

npx pwpr --url=example.com --output=example.html
# prerenders https://example.com and saves to ./example.html

npx pwpr --url=example.com --sleep=5000
# prerenders https://example.com after waiting for 5 seconds

npx pwpr --url=example.com --js=10000 --selector='.js-loaded-class-name'
# prerenders https://example.com after waiting for *up to* 10 seconds for the specified
# selector to be matched in the page with "docment.querySelector()" and prints to stdout

npx pwpr --url=example.com --ua='Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0'
# prerenders https://example.com and uses the specified user agent string in network requests

npx pwpr --url=example.com --js=10000 --selector='.js-loaded-class-name' --sleep=10000
# prerenders https://example.com after waiting for *up to* 10 seconds for the specified
# selector to be matched in the page with "docment.querySelector()" and prints to stdout
# **note that the --sleep option is ignored because the --selector option was provided

npx pwpr --url=file://somefile.txt --output=example.html
# tries to prerender https://file://somefile.txt and blows up
```

---
_Source: https://npm.io/package/pwpr · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
