4

I'm trying, and failing, to open the website https://www.bet365.com with selenium and python. In my code, I've followed these steps.

First, I just did

from selenium import webdriver
browser=webdriver.Chrome()
browser.get('https://www.bet365.com')

After a while, Bet365 changed something and doing the above returned a gray screen. In order to bypass that, I did the following

from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument("window-size=1920,1080")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
browser=webdriver.Chrome(options=options,executable_path=r"chromedriver.exe")

browser.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
                                  "source": """
                                    Object.defineProperty(navigator, 'webdriver', {
                                      get: () => undefined
                                    })
                                  """
                                })
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.4240.198 Safari/537.36'})
browser.get('https://www.bet365.com')

Since last saturday, doing this, or even the first script, returns the out of memory screen. As this is the first attempt, and it happens as well if I erase cookies and cache and restart the computer, I'm led to believe the problem is not in my computer, which loads other pages just as fine, not Chrome, which loads Bet365 in a regular browser just fine as well, but with Bet365 and selenium.

How can I solve this?

EDIT Someone thought this thread answered my question Chrome driver for Selenium stuck in grey screen on bet365 site

Although I appreciate the effort, the gray screen was a problem I have already solved, as I put in my question. The Out of memory error is the one I want to fix.

puppet
  • 707
  • 3
  • 16
  • 33

1 Answers1

4

After a few days of research, I saw that when I changed cdc_ to xyz_ I was successful in opening the Bet365 website.

Solution: I opened the file chromedriver.exe with Notepad ++ and searched and replaced "cdc_" with "xyz_" and saved the file.

Edit 2021/02/06:

The bet ended up blocking access to this solution, add this line to the options of the chromedriver that will open again:

options.add_argument('--disable-blink-features=AutomationControlled')

There, he opened the page normally.

  • It worked like a charm. Thank you very much. Can you explain why? I tried chromium in different versions, as well as firefox, and none of them were capable of working – puppet Dec 06 '20 at 12:48
  • It worked for me. I tried a lot of things and this was the only one that solved the problem. thks – rodrigorf Dec 11 '20 at 17:56
  • Is it still working for you? Few days ago Bet365 blocked program again and now it s not working even with changed chromedriver. – Skat Feb 02 '21 at 16:27
  • I was going to say the same. Until yesterday it worked just fine, but today it stopped and we are again with the out of memory screen. Perhaps Carlos Morato can enlighten us about what just happened. – puppet Feb 05 '21 at 23:10
  • Yes, the bet ended up blocking the chromedriver's access to the site, however when adding the line the options it opened again here: options.add_argument('--disable-blink-features=AutomationControlled') – Carlos Morato Feb 07 '21 at 01:05
  • Does this solution still work? Doesn't seem to be working for me, even with the added argument – Hews Mar 29 '21 at 04:22