问题描述
我一直在使用Selenium + Chromedriver,发现根据启用或禁用headless会得到不同的结果.经过一番调查,我发现无头"不包含Accept-Language
标头.
I have been playing around with Selenium + Chromedriver and I noticed I get different results based on if headless is enabled or disabled. After some investigation I found out that "headless" does not include the Accept-Language
header.
反正有手动将其添加到标题中吗?
Is there anyway to manually add this in the headers?
推荐答案
这就是Google chrome所做的.解决它的一种方法是使用代理并为您修改标题.或者,您可以使用Firefox驱动程序,因为使用无头选项时该驱动程序不会发送不同的标头.
That's what Google chrome does. One way around it would be to use a proxy and modify the headers for you. Or you can use the Firefox driver as that driver does not send different headers when using the headless option.
这篇关于带有chromedriver的硒根据“无头"的结果给出了不同的结果.争论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!