Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用adblocker扩展和使用python selenium的无头chrome驱动程序_Python_Selenium_Google Chrome Extension_Selenium Chromedriver_Google Chrome Headless - Fatal编程技术网

使用adblocker扩展和使用python selenium的无头chrome驱动程序

使用adblocker扩展和使用python selenium的无头chrome驱动程序,python,selenium,google-chrome-extension,selenium-chromedriver,google-chrome-headless,Python,Selenium,Google Chrome Extension,Selenium Chromedriver,Google Chrome Headless,我尝试使用adblocker并无头运行我的chrome驱动程序,单独使用这两个选项不会产生错误,但添加这两个选项会产生以下错误: selenium.common.exceptions.WebDriverException:消息:未知错误:未能等待加载扩展背景页:chrome-extension://alplpnakfeabeiebipdmaenpmbgknjce/_generated_background_page.html 来自未知错误:找不到页面:chrome-extension://alp

我尝试使用adblocker并无头运行我的chrome驱动程序,单独使用这两个选项不会产生错误,但添加这两个选项会产生以下错误:

selenium.common.exceptions.WebDriverException:消息:未知错误:未能等待加载扩展背景页:chrome-extension://alplpnakfeabeiebipdmaenpmbgknjce/_generated_background_page.html 来自未知错误:找不到页面:chrome-extension://alplpnakfeabeiebipdmaenpmbgknjce/_generated_background_page.html

据我所知,adblock扩展正在查找背景页,但没有找到它,因为它处于无标题模式。(无头模式下工作正常)

可测试代码(给出错误):

我尝试过的事情:

·不同的adblocker。(可以提供列表)

·让代码在不同的地方等待。(正如错误所说,它未能等待 (某物)

·无头但没有广告拦截器。(比使用adblocker和窗口GUI显示时慢)

·多次问谷歌这个问题。(没用…)


如果有人知道一种在使用python selenium的同时使用adblock扩展来运行chrome浏览器headless的解决方案,我也想知道,谢谢。

在headless模式下使用扩展来运行selenium目前是不可能的,而且谷歌似乎不打算在短期内支持这种解决方案。
您可以找到更多信息

可能重复。请检查以下SO链接:非重复。我不够清楚,我可以运行没有问题的adblocker,我可以运行没有问题的chrome headless,这是同时运行这两个给我一个错误。嗨,我也遇到了这个问题。Chrome开发人员表示,要让headless与扩展一起工作,需要做太多的工作。。。考虑到firefox可以做到这一点,这似乎是不真实的。是的,你可以在这里查看我的答案:----------
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
# adblocker crx file, downloaded from: https://chrome-extension-downloader.com/
chrome_options.add_extension("Adblocker-for-Chrome-NoAds_v3.2.0.1.crx")
chrome_options.add_argument("headless")

driver = webdriver.Chrome(options=chrome_options)