Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doesn't work on discord #15

Open
niettcat opened this issue Apr 28, 2023 · 1 comment
Open

doesn't work on discord #15

niettcat opened this issue Apr 28, 2023 · 1 comment

Comments

@niettcat
Copy link

doesn't work on discord. got error: failed to find element matching selector ".h-captcha"

@UDIA-GOD
Copy link

UDIA-GOD commented Sep 26, 2023

it does

import puppeteer from 'puppeteer';
import { solveCaptcha } from 'nocaptchaai-puppeteer';

const URL = 'https://accounts.hcaptcha.com/demo?sitekey=4c672d35-0701-42b2-88c3-78380b0db560';

const API_KEY = 'api_key'; // <-- your API key here

const main = async (): Promise<void> => {
  const browser = await puppeteer.launch({ channel: 'chrome', headless: false });
  const page = await browser.newPage();
  await page.goto(URL);
  await page.waitForNetworkIdle();

  await solveCaptcha(page, API_KEY, 'uid', 'pro', false);

  await page.waitForSelector('#hcaptcha-demo-submit');

  // Click the button with id "hcaptcha-demo-submit"
  await page.click('#hcaptcha-demo-submit');

  // Wait for the navigation to complete after clicking the button
  //await page.waitForNavigation({ waitUntil: 'load' });


  const htmlContent = await page.content();
  const regex = /Token:<p><\/p><p>(.*?)<\/p>/;

  // Use the regular expression to extract the token
  const match = htmlContent.match(regex);

  if (match && match.length > 1) {
    const token = match[1];
    console.log('hCaptcha Response Token:', token);
  } else {
    console.log('hCaptcha Response Token not found in the HTML content.');
  }

  await browser.close();
};

main();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants