【发布时间】:2022-01-25 16:35:03
【问题描述】:
是否可以在 Python 中使用 Selenium 访问 https://www.corsair.com/ 而不会被 Corsair 阻止?
当我尝试在 Selenium 中加载页面时,它一直给我这个错误消息:
我试图绕过它,将用户代理更改为随机的,这并没有解决问题。
这是我的代码:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from fake_useragent import UserAgent
options = webdriver.ChromeOptions()
options.add_argument("window-size=1400,600")
ua = UserAgent()
user_agent = ua.random
print(user_agent)
options.add_argument(f'user-agent={user_agent}')
options.add_argument("start-maximized")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=options)
print('Loading Corsair Website ...')
driver.get("https://www.corsair.com/")
【问题讨论】:
-
在我最初的运行中,它有效,但在随后的运行之后,他们的网站以某种方式检测到它是自动化软件。通常在这些情况下修改用户代理对我有帮助。
-
@GevorgChobanyan 是的,当我第一次尝试它时,它也能正常工作,但经过多次尝试,它没有。您是否尝试将我的代码与随机用户代理一起使用?它对你有用吗?
标签: python python-3.x selenium selenium-webdriver selenium-chromedriver