deno-puppeteer
PuppeteerのDenoポート
作者はLucaさん
https://deno.land/x/puppeteer
/icons/GitHub.iconlucacasonato/deno-puppeteer
使う前に、backgroundで使用するbrowserを予めinstallしておく必要がある
chromeの場合
$ PUPPETEER_PRODUCT=chrome deno run -A --unstable https://deno.land/x/puppeteer@9.0.0/install.ts
firefoxの場合
$ PUPPETEER_PRODUCT=firefox deno run -A --unstable https://deno.land/x/puppeteer@9.0.0/install.ts
demo
このページをscreenshotして保存する
code:sh
deno run -A --unstable https://scrapbox.io/api/code/deno-ja/deno-puppeteer/script.js
code:script.js
import puppeteer from "https://deno.land/x/puppeteer@9.0.2/mod.ts";
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto("https://scrapbox.io/deno-ja/deno-puppeteer");
await page.screenshot({ path: "deno-puppeteer.png" });
await browser.close();
WSLだとエラーが出て動かないtakker.icon
code:log
PUPPETEER_PRODUCT=firefox deno run -A --unstable https://scrapbox.io/api/code/deno-ja/deno-puppeteer/script.js
error: Uncaught (in promise) BadResource: Bad resource ID
const result = await reader.read(inspectArr);
^
at async read (deno:runtime/js/12_io.js:105:19)
at async readDelim (https://deno.land/std@0.93.0/io/bufio.ts:652:20)
at async readStringDelim (https://deno.land/std@0.93.0/io/bufio.ts:702:20)
at async readLines (https://deno.land/std@0.93.0/io/bufio.ts:711:18)
at async waitForWSEndpoint (https://deno.land/x/puppeteer@9.0.2/src/deno/BrowserRunner.ts:167:20)
at async BrowserRunner.setupConnection (https://deno.land/x/puppeteer@9.0.2/src/deno/BrowserRunner.ts:145:31)
at async FirefoxLauncher.launch (https://deno.land/x/puppeteer@9.0.2/src/deno/Launcher.ts:275:26)
at async https://scrapbox.io/api/code/deno-ja/deno-puppeteer/script.js:3:17