{"id":23666640,"url":"https://github.com/redsift/go-render","last_synced_at":"2025-12-11T06:30:14.182Z","repository":{"id":57528410,"uuid":"59509163","full_name":"redsift/go-render","owner":"redsift","description":"Webkit2 based headless render tool","archived":false,"fork":false,"pushed_at":"2020-02-28T23:48:25.000Z","size":133,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":20,"default_branch":"master","last_synced_at":"2024-12-29T07:33:16.619Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/redsift.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-23T18:41:05.000Z","updated_at":"2020-06-03T21:43:28.000Z","dependencies_parsed_at":"2022-08-30T11:50:42.630Z","dependency_job_id":null,"html_url":"https://github.com/redsift/go-render","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redsift%2Fgo-render","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redsift%2Fgo-render/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redsift%2Fgo-render/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redsift%2Fgo-render/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/redsift","download_url":"https://codeload.github.com/redsift/go-render/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239674986,"owners_count":19678507,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-29T07:33:23.158Z","updated_at":"2025-12-11T06:30:14.134Z","avatar_url":"https://github.com/redsift.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-render\n\n[![CircleCI](https://circleci.com/gh/redsift/go-render.svg?style=svg)](https://circleci.com/gh/redsift/go-render) \n\n[![Docker Repository on Quay](https://quay.io/repository/redsift/go-render/status \"Docker Repository on Quay\")](https://quay.io/repository/redsift/go-render)\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/redsift/go-render)](https://goreportcard.com/report/github.com/redsift/go-render)\n\n\nSimple WebKit2 based headless HTML/SVG rasterizer. \n\n# Docker\n\nBuilding and running a headless Webkit is typically not trivial. You need a pretty extensive build and runtime environment along with services like a virtual frame buffer. In addition to wrapping this functionality as a go library, this repository includes a sane command line binary that gives you access to a few simple commands. This binary is packages as a public Docker container and gives you access to headless rendering on the Docker compatible platform of your choice.\n\n## Metadata\n\nGet basic page and timing information.\n\n    $ docker run quay.io/redsift/go-render metadata www.google.com\n    {\n        \"Title\": \"Google\",\n        \"URI\": \"https://www.google.co.uk/?gfe_rd=cr\\u0026ei=EGxRV9_DMdTG8AefmYeoCw\\u0026gws_rd=ssl\",\n        \"Timing\": {\n            \"Start\": 0.0008351950000000001,\n            \"Load\": 0.346783985,\n            \"Finish\": 0.34761918\n        }\n    }\n\n## Screenshot\n\nGet a PNG of the page.\n\n    $ docker run quay.io/redsift/go-render snapshot www.yahoo.com -f png \u003e yahoo.png\n\n## Javascript\n\nExecute some javascript in the context of a loaded page. e.g. Page DOM validation tests.\n\n\t$ docker run quay.io/redsift/go-render javascript --js window.location.hostname www.bbc.co.uk\n\nYou may also supply a `.js` file to execute as the parameter.\n\n## Additional Examples\n\n### Metadata\n\n\t# Local filesystem rendering\n\t$ ... metadata file:///opt/gopath/src/github.com/redsift/go-render/test/local.html\n\n#### Format\n\n`--format` allows extraction of selected fields from the JSON file. e.g. `--format=\"{{.Title}}\"` to just grab the title\nor `-f \"{{json .Timing}}\"` to get the timing information.\n\n### Javascript\n\n\t$ ... javascript -j \"\\\"js=\\\" + window.location.hostname\"  www.google.com\n\n#### Local .js file\n\n    $ cat ./test.js\n    function t() {\n        return { Hostname: window.location.hostname, Pathname: window.location.pathname };\n    }\n    t();\n    \n    # Execute a local file, exceptions will set a non-zero exit code\n\t$ docker run -v test.js:/tmp/host quay.io/redsift/go-render \\ \n\t  \tjavascript --js /tmp/host/test.js www.google.com\n    \n\t# Extract a field from the JSON object\n\t$ ... javascript -j ./test.js -f {{.Hostname}} www.google.com\n\n### Snapshot\n\n\t# Capture a png to stdout\n\t$ ... snapshot www.google.com\n\n\t# Capture a webp as a file\n\t$ ... snapshot -o google.webp www.google.com\n\n\t# Capture multiple URLS and construct filenames from the hostname\n\t$ render snapshot -o grab-{{.Host}}.png www.google.com www.yahoo.com\n\n## Using Stdin\n\nIn addition to passing the URLs on the command line, you may omit the argument and `go-render` will read from the command line. \n\n\t# From stdin where `urls.txt` is a simple list of URLs separated by a newline.\n\t$ cat urls.txt | ... snapshot -o list-{{.Index}}.png\n\n# How does it work?\n\nThis library uses a version of [go-webkit2](https://github.com/sourcegraph/go-webkit2). The docker image bundles the [Xvfb](https://en.wikipedia.org/wiki/Xvfb) virtual frame-buffer. The runtime image is stripped down using syscall tracing to reduce the size requirements for the binary by an order of magnitude.\n\n\n# Developers\n\n## Xvfb\n\n`xdpyinfo` can provide stats on the virtual frame buffer.\n        \n        \n## Tracing\n        \n        sudo apt-get install strace\n        \n        sudo strace -f -o $CIRCLE_ARTIFACTS/bash.strace.out -p 49350\n        \n# Know issues\n\n- Due to timing issues with the cleanup of the process tree, WebKit might occasionally emit errors as it shuts down. e.g. `(WebKitWebProcess:26): Gdk-WARNING **: WebKitWebProcess: Fatal IO error 11 (Resource temporarily unavailable) on X server :1.`        \n- Some URLs may not successfully snapshot. e.g. `docker run quay.io/redsift/go-render snapshot www.shazam.com` -\u003e `render: error: Unable to create snapshot: There was an error creating the snapshot`. This is usually due to a 0x0 pixel display at the time of invoking the snapshot.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredsift%2Fgo-render","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredsift%2Fgo-render","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredsift%2Fgo-render/lists"}