Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Readme

Browserbase

Browserbase offers a reliable, high performance serverless developer platform to run, manage, and monitor headless browsers at scale. Leverage our infrastructure to power your web automation and AI agents.

Get started with Browserbase for free here.

If you have any questions, reach out to developer@browserbase.com.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { screenshotPage } from "https://esm.town/v/browserbase/browserbaseUtils";
import { Buffer } from "node:buffer";
import Jimp from "npm:jimp";
export async function blobReadPictureExample(request: Request): Promise<Response> {
const searchParams = new URL(request.url).searchParams;
const url = searchParams.get("url") || "https://www.browserbase.com";
const buffer = await screenshotPage(url);
console.log(url);
const img = await Jimp.read(Buffer.from(buffer.buffer));
return new Response(await img.getBufferAsync(Jimp.MIME_PNG), {
headers: {
"Content-Type": Jimp.MIME_PNG,
},
});
}
browserbase-httpapiscreenshotpageexample.web.val.run
September 6, 2024