URL: https://github.com/peterbe/html-getter

When Bun v1.3.12 was released last week, they subtly included a powerful feature, almost under the radar: WebView. It's like Playwright/Puppeteer but more limited, especially in terms of documentation.

I built a demo app based on it called html-getter which you can use like this:


bun run src/html-getter.ts https://www.peterbe.com

That will open https://www.peterbe.com with Chrome or Chromium or WebKit and evaluate the following JavaScript expression: document.documentElement.outerHTML (which is the whole HTML source of the whole DOM) and print this to stdout.

or you can use it like this:


bun run src/html-getter.ts --body --screenshot /tmp/page.png https://www.peterbe.com

which means it prints everything inside the <body>...</body> instead and at the same time, it dumps a screenshot of what it looks like, which can be useful for debugging.

What's cool about this is that you no longer need to install playwright or puppeteer. Scraping HTML is just one of many applications you can use WebView for. I wouldn't use it for automated headless browser testing though because the documentation, tooling, and APIs for Playwright is still so much much better.

WARNING

At the time of writing this, I am unable, on macOS, to compile this Bun script into a binary. When I do, this happens:


$ bun run build
$ bun build src/html-getter.ts --target=bun --outfile out/html-getter --compile --bytecode
  [14ms]  bundle  1 modules
  [77ms] compile  out/html-getter
$ ./out/html-getter https://www.peterbe.com
[1]    70304 killed     ./out/html-getter https://www.peterbe.com

The same worked on my x64 Linux server, but to get this to compile on macOS might need some more careful thought.

Comments

Your email will never ever be published.

Previous:
Bestest security tip for updating packages with Bun April 14, 2026 Bun
Related by category:
Bun vs. Go for a basic web server benchmark October 24, 2025 Bun
Benchmarking oxlint vs biome December 12, 2025 Bun, TypeScript
Testing out vite 8 on SPA: Vite 8 is 5x faster December 6, 2025 Bun, TypeScript
Hosting your static web site with Firebase Hosting November 3, 2025 Bun
Related by keyword:
The technology behind You Should Watch January 28, 2023 React, Firebase, JavaScript, You Should Watch
How to submit a form with Playwright August 3, 2021 JavaScript
How to use minimalcss without a server April 24, 2020 Web development, Node, JavaScript
How's My WiFi? December 8, 2017 Node, JavaScript, macOS