npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pwpr

v4.2.2

Published

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

Downloads

878

Readme

PWPR (Playwright Pre-Render)

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 Downloads/week License

USAGE

$ 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

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