同时使用这些选项无法按预期工作:
options.add_argument('--disable-javascript')
options.add_argument('--headless')
When I disable JavaScript without using headless mode, it looks like this.
But when I try to disable JavaScript with headless mode, it looks like this.
同时使用这些选项无法按预期工作:
options.add_argument('--disable-javascript')
options.add_argument('--headless')
When I disable JavaScript without using headless mode, it looks like this.
But when I try to disable JavaScript with headless mode, it looks like this.
1条答案
按热度按时间djmepvbi1#
如果您使用新的headless模式,现在可以在headless Chrome中禁用JavaScript:
新方式(2023年):
--headless=new
(Chrome 109及以上版本)前一种方式:
--headless=chrome
( chrome 96- chrome 108)(The旧方法:
--headless
)这里有更多的信息:www.example.comhttps://bugs.chromium.org/p/chromium/issues/detail?id=706008#c36
有关更新的Chrome 109信息,请参阅:https://github.com/chromium/chromium/commit/e9c516118e2e1923757ecb13e6d9fff36775d1f4
您可以使用下面的代码作为选项,在无头运行时完全禁用JavaScript: