Spaces:
Sleeping
Sleeping
File size: 1,488 Bytes
cf88d39 af972a5 1c93e9d b77d5ce 25c507d 1c93e9d af972a5 1c93e9d af972a5 1c93e9d cf88d39 25c507d 1c93e9d 5dab452 25c507d cf88d39 1c93e9d cf88d39 1c93e9d cf88d39 1c93e9d cf88d39 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
import { chromium, devices } from 'playwright';
// import { createSecureServer } from 'node:http2';
import { Hono } from 'hono';
import { serve } from '@hono/node-server';
import { serveStatic } from '@hono/node-server/serve-static';
// https://t1ckbase-remote-playwright-test.hf.space
const app = new Hono();
app.use('/screenshot.png', serveStatic({ path: './screenshot.png' }));
app.get('/', (c) => c.text('Hello Node.js!'));
// app.get('/json', async (c) => await fetch('http://127.0.0.1:9222/json'));
serve({
port: 3000,
fetch: app.fetch,
// createServer: createSecureServer,
});
const browser = await chromium.launch({
headless: true,
args: ['--disable-blink-features=AutomationControlled' /* , '--remote-debugging-port=9222' */],
channel: 'chrome',
});
const context = await browser.newContext({
...devices['Desktop Chrome'],
colorScheme: 'dark',
// viewport: null,
viewport: { width: 1920, height: 1080 },
// deviceScaleFactor: undefined,
});
const page = await context.newPage();
// await page.goto('https://bot.sannysoft.com', { waitUntil: 'load' });
// await page.goto('https://www.browserscan.net/bot-detection');
// await page.goto('https://fingerprintjs.github.io/BotD/main/');
await page.goto('https://translate.google.com/?sl=auto&tl=en&op=images', { waitUntil: 'load' });
await page.screenshot({ path: 'screenshot.png', fullPage: true });
// await page.waitForEvent('close', { timeout: 0 });
await context.close();
await browser.close();
|