Public
Edited
Dec 16, 2023
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
// Launch the browser and open a new blank page
const browser = await newBrowser(wsUrl);
try {
const page = await browser.newPage();

// return;

// Navigate the page to a URL
await page.goto("https://pptr.dev");

// Set screen size
await page.setViewport({ width: 1080, height: 1024 });

await Promises.delay(3000);

const imgUrl = await page.screenshot({
type: "png",
encoding: "base64",
fullPage: true
});
return htl.html`<img src="data:image/png;base64,${imgUrl}" />`;
} finally {
await browser.close();
}
}
Insert cell
Insert cell
Insert cell
async function newBrowser(wsUrl) {
const transport = await BrowserWebSocketTransport.create(wsUrl);
const browser = await connectToCdpBrowser({
transport
});
return browser;
}
Insert cell
import {
connectToCdpBrowser,
BrowserWebSocketTransport
} from "@kotelnikov/webrun-devtools-puppeteer-ws"
Insert cell
import { toc } from "@nebrius/indented-toc"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more