Bet365 detects Selenium Chromedriver

Viewed 586

I have a problem, that https://bet365.com started to block Selenium bots. It's stuck on the white screen.

I've tried everything, now my code looks like:

username = os.getenv("USERNAME")
userProfile = "C:\\Users\\" + username + "\\AppData\\Local\\Google\\Chrome\\User Data\\Default"

opts = webdriver.ChromeOptions()

opts.add_argument("user-data-dir={}".format(userProfile))
opts.add_argument('--profile-directory=Profile 2')

opts.add_argument("user-agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36'")

opts.add_experimental_option('useAutomationExtension', False)
opts.add_experimental_option("excludeSwitches", ["enable-automation", "ignore-certificate-errors", "safebrowsing-disable-download-protection", "safebrowsing-disable-auto-update", "disable-client-side-phishing-detection"])

opts.add_argument("--disable-notifications")
opts.add_argument("--disable-blink-features")
opts.add_argument("--disable-blink-features=AutomationControlled")
opts.add_experimental_option("excludeSwitches", ["enable-automation"])
opts.add_experimental_option('useAutomationExtension', False)

self.browser = webdriver.Chrome(options=opts, executable_path=self.resource_path("chromedriver.exe"))

window_size = self.browser.execute_script("""
        return [window.outerWidth - window.innerWidth + arguments[0],
          window.outerHeight - window.innerHeight + arguments[1]];
        """, width, height)
self.browser.set_window_size(*window_size)

self.browser.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
    "source": """
        Object.defineProperty(navigator, 'webdriver', {
        get: () => undefined
    })
    """
})

self.browser.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
    "source": """
        Object.defineProperty(navigator, 'languages', {
        get: () => ["en-US", "en", "es"]
    })
    """
})

self.browser.execute_cdp_cmd("Network.enable", {})
self.browser.execute_cdp_cmd("Network.setExtraHTTPHeaders", {"headers": {"User-Agent": "browser1"}})

self.browser.execute_cdp_cmd('Network.setUserAgentOverride',
            {"userAgent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36'})

Also I tried to launch bot on Firefox using geckodriver, and tried to launch it using phantomjs, but it also have no results. And the last, I tried to obfuscate JavaScript code in chromedriver.exe by changing $cdc_ to smth else ($aba_), bot launhes, all is ok, but the same no access to Bet365.

After launching programm browser is stuck on this: Bet365 Screenshot

And when I go to the website manually by myself, all is ok, it loads.

Can anyone help me with this problem?

0 Answers
Related