pwpr

    2.2.0 • Public • Published

    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)
    
    --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

    Install

    npm i pwpr

    DownloadsWeekly Downloads

    5

    Version

    2.2.0

    License

    MIT

    Unpacked Size

    11.4 kB

    Total Files

    8

    Last publish

    Collaborators

    • andrewbrey