Skip to content

kitsuyui/rendering-proxy

Repository files navigation

rendering-proxy

npm version codecov test Docker Pulls

Fetching rendered DOM easily and simply. Like cURL. Using Headless Chromium.

rendering-proxy

So this library provides simplicity in these cases:

  • Crawlers
  • Text browsers
  • Command line interface like curl wget

Installation

published on npm

$ npm install rendering-proxy
$ yarn add rendering-proxy
$ pnpm add rendering-proxy

Usage

$ rendering-proxy --help
rendering-proxy <command>

Commands:
  rendering-proxy cli [url]  CLi mode
  rendering-proxy server     Server mode

Options:
  --version  Show version number                                       [boolean]
  --help     Show help                                                 [boolean]

CLI mode

$ yarn run rendering-proxy cli https://example.com/
<html><head>
...
</body></html>

Server mode

$ yarn run rendering-proxy server --port=8080
$ curl http://localhost:8080/https://example.com/
<html><head>
...
</body></html>

evaluate

CLI mode

When -e, --evaluate is specified, JavaScript code is evaluated before getting DOM.

$ yarn run rendering-proxy cli https://example.com/ -e 'document.title = "updated"' -e 'document.title += " twice"'
<!DOCTYPE html><html><head>
    <title>updated twice</title>
...

Server mode

Send the options via request header X-Rendering-Proxy (case-insensitive). Receive the results via request header X-Rendering-Proxy (case-insensitive).

curl -H 'X-Rendering-Proxy: {"evaluates": ["1 + 1"], "waitUntil": "load"}' --include http://localhost:8080/https://example.com/
HTTP/1.1 200 OK
...
x-rendering-proxy: [{"success":true,"result":2,"script":"1 + 1"}]
...

<!DOCTYPE html><html><head>
    <title>Example Domain</title>

LICENSE

The 3-Clause BSD License. See also LICENSE file.