Skip to content

Instantly share code, notes, and snippets.

@ofarukcaki
Last active April 7, 2023 08:49
Show Gist options
  • Save ofarukcaki/e1119d0321ca34a34fca44cfd11c5f38 to your computer and use it in GitHub Desktop.
Save ofarukcaki/e1119d0321ca34a34fca44cfd11c5f38 to your computer and use it in GitHub Desktop.
const puppeteer = require("puppeteer");
(async () => {
const browser = await puppeteer.launch({
headless: false,
defaultViewport: false
});
const page = (await browser.pages())[0];
// imaginary page with a captcha on it
await page.goto(
"https://example.com/captcha-page",
{ waitUntil: "load" }
);
const elementHandler = await page.$("#captcha-container img");
// base64String contains the captcha image's base64 encoded version
const base64String = await elementHandler.screenshot({ encoding: "base64" });
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment