website-builde / test-browser-pw.ts
Daviddolor's picture
Single-process Chromium, fixed visual-polish prompt, Docker config for HF Space
ec675f2
Raw
History Blame Contribute Delete
572 Bytes
import { chromium } from "playwright";
async function crawl(url: string) {
const browser = await chromium.launch({
headless: true,
args: ["--no-sandbox", "--disable-dev-shm-usage"],
});
const page = await browser.newPage();
await page.goto(url, { waitUntil: "networkidle", timeout: 20000 });
const title = await page.title();
const text = (await page.textContent("body"))?.slice(0, 2000) || "";
await browser.close();
return { url, title, text };
}
(async () => {
console.log(JSON.stringify(await crawl("https://example.com"), null, 2));
})();