From 7680dd6fc25f761237654830079ffb467423e284 Mon Sep 17 00:00:00 2001 From: Xewdy444 Date: Tue, 2 Jul 2024 12:13:34 -0500 Subject: [PATCH] Create solve_with_sitekey.py --- examples/recaptchav2/solve_with_sitekey.py | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 examples/recaptchav2/solve_with_sitekey.py diff --git a/examples/recaptchav2/solve_with_sitekey.py b/examples/recaptchav2/solve_with_sitekey.py new file mode 100644 index 0000000..ed9fe0e --- /dev/null +++ b/examples/recaptchav2/solve_with_sitekey.py @@ -0,0 +1,40 @@ +from playwright.sync_api import sync_playwright + +from playwright_recaptcha import recaptchav2 + +RECAPTCHA_HTML = """ + + + + + + +
+ + +""" + + +def main() -> None: + with sync_playwright() as playwright: + browser = playwright.firefox.launch() + page = browser.new_page() + + # It is important to load a website before setting the reCAPTCHA HTML. + # If you don't, the reCAPTCHA will give you an "Invalid domain for site key" error. + page.goto("https://www.google.com/", wait_until="commit") + + page.set_content( + RECAPTCHA_HTML.format(sitekey="6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-") + ) + + with recaptchav2.SyncSolver(page) as solver: + token = solver.solve_recaptcha(wait=True) + print(token) + + +if __name__ == "__main__": + main()