无法运行Selenium脚本无头



我创建了一个脚本来自动执行每周一需要执行的任务。为此,我用以下代码启动一个驱动程序:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
s = Service(ChromeDriverManager().install())
chrome_options = webdriver.ChromeOptions()
chrome_options.headless = True
driver = webdriver.Chrome(service=s, chrome_options=chrome_options)

从代码片段中,我发现这应该在后台运行我的脚本。然而,我得到了以下信息:

[0117/134345.023:INFO:CONSOLE(2)] "Elevio warning. 
Elevio is disabled. Either via JavaScript API, or from page settings. undefined", source: https://cdn.elev.io/sdk/main/v4/1641517832207/elevio-main.js (2)
[0117/134345.994:INFO:CONSOLE(2)] "Elevio warning. 
Elevio is disabled. Either via JavaScript API, or from page settings. undefined", source: https://cdn.elev.io/sdk/main/v4/1641517832207/elevio-main.js (2)
[0117/134348.880:INFO:CONSOLE(3)] "Hotjar not launching due to suspicious userAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/97.0.4692.71 Safari/537.36", source: https://static.hotjar.com/c/hotjar-2048401.js?sv=6 (3)
[0117/134349.260:INFO:CONSOLE(3)] "Hotjar not launching due to suspicious userAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/97.0.4692.71 Safari/537.36", source: https://static.hotjar.com/c/hotjar-2048401.js?sv=6 (3)

有人知道问题可能是什么以及如何解决吗?当我不在后台运行脚本时,一切都正常。

运行:

  • Python 3.9.4
  • 硒4.1.0
  • 网络驱动程序管理器3.5.2

这似乎是一个已知的问题,与以无头模式发送的用户代理有关,请查看以下后

HotJar可疑的UserAgent错误,在谷歌上什么都没有,试图运行一个用于体育赔率跟踪的python scraper工具

相关内容

  • 没有找到相关文章

最新更新