seleniumbase / SeleniumBase

📊 Python's all-in-one framework for web crawling, scraping, testing, and reporting. Supports pytest. UC Mode provides stealth. Includes many tools.
https://seleniumbase.io
MIT License
4.46k stars 909 forks source link

How to bypass reCAPTCHA #2755

Closed adarmawan117 closed 1 month ago

adarmawan117 commented 1 month ago

As you said in this page https://seleniumbase.io/help_docs/uc_mode/#here-are-the-driver-specific-methods-added-by-seleniumbase-for-uc-mode-uc-uctrue **

As an ethical hacker / cybersecurity researcher who builds bots that bypass CAPTCHAs for sport, the CAPTCHA service that I personally recommend for keeping bots out is Google's reCAPTCHA:

**

Is there any way to bypass reCAPTCHA. Because i dont see any example on https://seleniumbase.io/.

Thanks

This is my code

def wait_till_search_bar_visible(sb):
    sb.highlight('input[id="q"]', timeout=20)

with SB(
        uc=True,
        incognito=True,
        maximize=True,
        demo=True,
        highlights=6,
        undetectable=True,
) as sb:
    link = 'https://www.lazada.co.id/shop/samsung/'
    sb.open(link)
    wait_till_search_bar_visible(sb)

    sb.click('//a[contains(@href, "All-Products")]')
    # reCAPTCHA visible here

    wait_till_search_bar_visible(sb)
mdmintz commented 1 month ago

Here's a working script for reCAPTCHA bypass:

from seleniumbase import Driver

driver = Driver(uc=True)
try:
    url = "seleniumbase.io/apps/recaptcha"
    driver.uc_open_with_reconnect(url, 4)
    driver.switch_to_frame("iframe")
    driver.uc_click("span")
    driver.sleep(3)
finally:
    driver.quit()

Google does a lot of IP-address tracking, so after running that script a certain number of times, you may get blocked: Not because they detect Selenium, but because of the unusual web activity.

adarmawan117 commented 1 month ago

So, i need to change my ip address regularly.?

mdmintz commented 1 month ago

That depends on the frequency that your scripts run at. If running a lot of scripts on the same website often (and that site uses reCAPTCHA), then you might need to change the IP Address more often, which you can do via the proxy arg if you already have a proxy server to use.

adarmawan117 commented 1 month ago

Ah yes, I forgot with proxy. 😂 Thanks, case close.