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

Handling Captcha Before doing other Actions #28

Closed
waelbenmustapha opened this issue Mar 27, 2024 · 1 comment
Closed

Handling Captcha Before doing other Actions #28

waelbenmustapha opened this issue Mar 27, 2024 · 1 comment

Comments

@waelbenmustapha
Copy link

An issue I've encountered involves bypassing the captcha and ensuring it's fully processed before attempting any interactions with the page, such as inputting login credentials. Even with the turnstile: true and fingerprint: true configurations enabled, my script attempts to interact with the page immediately after navigation, before the captcha can be resolved. To work around this, I've had to introduce a fixed delay (waitForTimeout(20000); at the start of the initial goto , but im wondering if it can like wait when it sees the cloudfare captcha , currently it solves the captcha but it just tries to find elements on the screen which are not yet available since the captcha is not finished yet . the issue also is that the cloudfare could popup on different times in the process , so i can't wait 20seconds after each step , is there a way to detect the captcha appearing through puppeteer-real-browser ?

thank you

this is a snippet from my code
`

const {
  browser: browserInstance,
  page,
  setTarget,
} = await connect({
  headless: false,
  fingerprint: true, // Injects a unique fingerprint ID into the page
  turnstile: true, // Automatically clicks on Captchas
  tf: true, // Use targetfilter to avoid detection initially
});

browser = browserInstance; 

setTarget({ status: false });
const page2 = await browser.newPage();
setTarget({ status: true });

// Navigate to the appointment page
await page2.goto(
  "https://xxx",
  { waitUntil: "domcontentloaded" }
);
// Wait for 5 seconds
await page2.waitForTimeout(20000);


// Login
await page2.focus("#username");
await page2.type("#username", "xxxxx@gmail.com");

await page2.focus("#password");
await page2.type("#password", "xxxxx");

`

@zfcsoftware
Copy link
Owner

https://github.com/zfcsoftware/puppeteer-real-browser/blob/main/src/module/turnstile.js
The above file provides the Captcha decoding function. First it checks if there is an iframe. If there is, it checks if there is a cgeckbox and clicks if there is. However, I haven't added any notification system that the captcha appears or is resolved in the process. I will add it in the future. If it is a Waf Captcha, if you don't use domcontentloaded, it waits until it is resolved. If it is a captcha in the form, we have not added a code that detects it for now, but this can be detected by making a few additions to the above file.

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