Is there any way to load this site using selenium?
CodePudding user response:
In my case,it's loading. You can just run the code to see the result
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options
import time
options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
#options.add_argument("--headless")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('excludeSwitches', ['enable-logging'])
options.add_experimental_option('useAutomationExtension', False)
options.add_argument('--disable-blink-features=AutomationControlled')
driver = webdriver.Chrome(ChromeDriverManager().install(), options=options)
url='https://www.pferdewetten.de/'
driver.get(url)
time.sleep(10)
CodePudding user response:
You can try not to give any options to the driver as they sometimes can cause these kind of problems.
CodePudding user response:
Possibly elenium driven ChromeDriver initiated google-chrome Browsing Context is geting detected as a bot.
To evade the detection you can make a few tweaks as follows:
- Remove the
--no-sandbox
argument and execute as non-root user. - Remove the
--disable-infobars
argument as it is no more effective. - Remove the
--disable-extensions
argument as it is no more effective. - Add an experimental option
"excludeSwitches", ["enable-automation"]
to evade detection. - Add an experimental option
'useAutomationExtension', False
to evade detection. - Add the argument
'--disable-blink-features=AutomationControlled'
to evade detection.
Effectively your code block will be:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
options = Options()
options.add_argument("start-maximized")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('excludeSwitches', ['enable-logging'])
options.add_experimental_option('useAutomationExtension', False)
options.add_argument('--disable-blink-features=AutomationControlled')
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
driver.get("https://www.pferdewetten.de/")
driver.quit()