try puppeteer-hcaptcha, but did not find iframe, #2

https://github.com/aw1875/puppeteer-hcaptcha
This commit is contained in:
Ralf Vogler 2022-03-03 17:09:37 +01:00
parent 3b3289dddf
commit 2dd1db3757
3 changed files with 2791 additions and 322 deletions

View file

@ -3,6 +3,8 @@ import path from 'path';
import { __dirname, stealth } from './util.js'; import { __dirname, stealth } from './util.js';
const debug = process.env.PWDEBUG == '1'; // runs non-headless and opens https://playwright.dev/docs/inspector const debug = process.env.PWDEBUG == '1'; // runs non-headless and opens https://playwright.dev/docs/inspector
import { hcaptcha } from "puppeteer-hcaptcha";
const URL_LOGIN = 'https://www.epicgames.com/login'; const URL_LOGIN = 'https://www.epicgames.com/login';
const URL_CLAIM = 'https://www.epicgames.com/store/en-US/free-games'; const URL_CLAIM = 'https://www.epicgames.com/store/en-US/free-games';
const TIMEOUT = 20 * 1000; // 20s, default is 30s const TIMEOUT = 20 * 1000; // 20s, default is 30s
@ -10,13 +12,15 @@ const TIMEOUT = 20 * 1000; // 20s, default is 30s
// https://playwright.dev/docs/auth#multi-factor-authentication // https://playwright.dev/docs/auth#multi-factor-authentication
const context = await chromium.launchPersistentContext(path.resolve(__dirname, 'userDataDir'), { const context = await chromium.launchPersistentContext(path.resolve(__dirname, 'userDataDir'), {
channel: 'chrome', // https://playwright.dev/docs/browsers#google-chrome--microsoft-edge channel: 'chrome', // https://playwright.dev/docs/browsers#google-chrome--microsoft-edge
headless: false, headless: true,
viewport: { width: 1280, height: 1280 }, viewport: { width: 1280, height: 1280 },
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36', // see replace of Headless in util.newStealthContext. TODO update if browser is updated! userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36', // see replace of Headless in util.newStealthContext. TODO update if browser is updated!
locale: "en-US", // ignore OS locale to be sure to have english text for locators locale: "en-US", // ignore OS locale to be sure to have english text for locators
args: [ // don't want to see bubble 'Restore pages? Chrome didn't shut down correctly.', but flags below don't work. args: [ // don't want to see bubble 'Restore pages? Chrome didn't shut down correctly.', but flags below don't work.
'--disable-session-crashed-bubble', '--disable-session-crashed-bubble',
'--restore-last-session', '--restore-last-session',
"--disable-dev-shm-usage",
"--disable-web-security",
], ],
}); });
@ -94,6 +98,8 @@ for (let i=1; i<=n; i++) {
// process.exit(1); // process.exit(1);
// } // }
// await page.waitForTimeout(3000); // await page.waitForTimeout(3000);
// <iframe class="" src="/store/purchase?highlightColor=0078f2&amp;offers=1-e...&amp;orderId&amp;purchaseToken&amp;showNavigation=true"></iframe>
await hcaptcha(page.frame({ url: /.*\/store\/purchase.*/ }).page()); // TODO Timeout waiting for selector "iframe[src*="newassets.hcaptcha.com"]" to be visible
await page.waitForSelector('text=Thank you for buying'); // EU: wait, non-EU: wait again await page.waitForSelector('text=Thank you for buying'); // EU: wait, non-EU: wait again
console.log('Claimed successfully!'); console.log('Claimed successfully!');
} catch (e) { } catch (e) {

3100
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -11,5 +11,8 @@
"playwright": "^1.17.1", "playwright": "^1.17.1",
"puppeteer-extra-plugin-stealth": "^2.9.0" "puppeteer-extra-plugin-stealth": "^2.9.0"
}, },
"type": "module" "type": "module",
"dependencies": {
"puppeteer-hcaptcha": "^4.1.5"
}
} }