带有chromedriver的硒根据“无头"的结果给出了不同的结果.争论 [英] Selenium with chromedriver gives different results based on "headless" argument

查看:99
本文介绍了带有chromedriver的硒根据“无头"的结果给出了不同的结果.争论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用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的硒根据“无头"的结果给出了不同的结果.争论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆