{"id":15031518,"url":"https://github.com/sourcegraph/webloop","last_synced_at":"2025-05-15T18:03:54.931Z","repository":{"id":45211595,"uuid":"13910654","full_name":"sourcegraph/webloop","owner":"sourcegraph","description":"WebLoop: Scriptable, headless WebKit with a Go API. Like PhantomJS, but for Go.","archived":false,"fork":false,"pushed_at":"2024-04-01T14:59:22.000Z","size":34,"stargazers_count":1371,"open_issues_count":22,"forks_count":84,"subscribers_count":50,"default_branch":"master","last_synced_at":"2025-05-15T18:03:38.621Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://sourcegraph.com/github.com/sourcegraph/webloop","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sourcegraph.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,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-10-27T21:25:01.000Z","updated_at":"2025-05-12T02:13:08.000Z","dependencies_parsed_at":"2024-06-21T17:09:23.414Z","dependency_job_id":"61642a9a-6efe-4d56-a718-cf9ac6b4fa03","html_url":"https://github.com/sourcegraph/webloop","commit_stats":{"total_commits":36,"total_committers":8,"mean_commits":4.5,"dds":0.2222222222222222,"last_synced_commit":"abd9d7573123112bda30a8fe320416da8dff2f9c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcegraph%2Fwebloop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcegraph%2Fwebloop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcegraph%2Fwebloop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcegraph%2Fwebloop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sourcegraph","download_url":"https://codeload.github.com/sourcegraph/webloop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254394720,"owners_count":22063984,"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-09-24T20:15:53.261Z","updated_at":"2025-05-15T18:03:54.868Z","avatar_url":"https://github.com/sourcegraph.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# WebLoop\n\nScriptable, headless WebKit with a Go API. Like [PhantomJS](http://phantomjs.org/), but for Go. Render static HTML versions of dynamic JavaScript applications, automate browsing, run arbitrary JavaScript in a browser window context, etc., all from Go or the command line.\n\n* [Documentation on Sourcegraph](https://sourcegraph.com/github.com/sourcegraph/webloop)\n\n\n## Requirements\n\n* [Go](http://golang.org) \u003e= 1.2rc1 (due to [#3250](https://code.google.com/p/go/issues/detail?id=3250))\n* [WebKitGTK+](http://webkitgtk.org/) \u003e= 2.0.0\n* [go-webkit2](https://sourcegraph.com/github.com/sourcegraph/go-webkit2)\n\nFor instructions on installing these dependencies, see the [go-webkit2\nREADME](https://sourcegraph.com/github.com/sourcegraph/go-webkit2@master/-/blob/README.md).\n\nTo install WebLoop, run: `go get github.com/sourcegraph/webloop/...`\n\n\n## Usage\n\n\n### Static HTML rendering reverse proxy\n\nThe included command `static-reverse-proxy` proxies a dynamic JavaScript application and serves an equivalent statically rendered HTML website to clients. Run it with:\n\n```\n$ go install github.com/sourcegraph/webloop/...\n$ static-reverse-proxy\n```\n\nFor example, to proxy a dynamic application at http://example.com and serve an\nequivalent statically rendered HTML website on http://localhost:13000, run:\n\n```\n$ static-reverse-proxy -target=http://example.com -http=:13000\n```\n\nRun with `-h` to see more information.\n\n\n### Rendering static HTML from a dynamic, single-page [AngularJS](http://angularjs.org) app\n\n`StaticRenderer` is an HTTP handler that serves a static HTML version of a\ndynamic web application. Use it like:\n\n```go\nstaticHandler := \u0026webloop.StaticRenderer{\n        TargetBaseURL:         \"http://dynamic-app.example.com\",\n        WaitTimeout:           time.Second * 3,\n        ReturnUnfinishedPages: true\n}\nhttp.Handle(\"/\", staticHandler)\n```\n\nSee the `examples/angular-static-seo/` directory for example code. Run the included binary with:\n\n```\n$ go run examples/angular-static-seo/server.go\n```\n\nInstructions will be printed for accessing the 2 local demo HTTP servers. Run\nwith `-h` to see more information.\n\n\n### Operating a headless WebKit and running arbitrary JavaScript in the page\n\n```go\npackage webloop_test\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"runtime\"\n\n\t\"github.com/gotk3/gotk3/gtk\"\n\t\"github.com/sourcegraph/webloop\"\n)\n\nfunc Example() {\n\tgtk.Init(nil)\n\tgo func() {\n\t\truntime.LockOSThread()\n\t\tgtk.Main()\n\t}()\n\n\tctx := webloop.New()\n\tview := ctx.NewView()\n\tdefer view.Close()\n\tview.Open(\"http://google.com\")\n\terr := view.Wait()\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"Failed to load URL: %s\", err)\n\t\tos.Exit(1)\n\t}\n\tres, err := view.EvaluateJavaScript(\"document.title\")\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"Failed to run JavaScript: %s\", err)\n\t\tos.Exit(1)\n\t}\n\tfmt.Printf(\"JavaScript returned: %q\\n\", res)\n\t// output:\n\t// JavaScript returned: \"Google\"\n}\n```\n\nSee `webloop_test.go` for more examples.\n\n\n## TODO\n\n* [Set up CI testing.](https://github.com/sourcegraph/webloop/issues/1) This\n  is difficult because all of the popular CI services run older versions of\n  Ubuntu that make it difficult to install WebKitGTK+ \u003e= 2.0.0.\n* Add the ability for JavaScript code to send messages to WebLoop, similar to\n  [PhantomJS's callPhantom]\n  (https://github.com/ariya/phantomjs/wiki/API-Reference-WebPage#oncallback)\n  mechanism.\n\n\n## Users\n\n* WebLoop is used to render static HTML pages on [Sourcegraph](https://sourcegraph.com) for search engine crawlers\n\n\n## Contributors\n\nSee the AUTHORS file for a list of contributors.\n\nSubmit contributions via GitHub pull request. Patches should include tests and\nshould pass [golint](https://github.com/golang/lint).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourcegraph%2Fwebloop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsourcegraph%2Fwebloop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourcegraph%2Fwebloop/lists"}