Out of memory Error in Python+Selenium first load

南笙酒味 提交于 2020-12-31 16:21:19

问题


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.


回答1:


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.

There, he opened the page normally.



来源:https://stackoverflow.com/questions/65071572/out-of-memory-error-in-pythonselenium-first-load

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!