隐藏页面特效

selenium Remote模式下报错 selenium/standalone-chrome:4.0.0: “Host header or origin header is specified and is not localhost”

问题

  1. 通过selenium-server-standalone注册node后,启动driver.get()报错
  2. github:issues: https://github.com/SeleniumHQ/selenium/issues/8326

代码区

from selenium.webdriver import Remote import time driver = Remote( command_executor='http://192.168.171.1:5555/wd/hub', desired_capabilities={ 'browserName': 'chrome', 'platform': 'ANY', 'version': '', 'javascriptEnabled': True } ) driver.get('http://www.baidu.com') driver.find_element_by_id('kw').send_keys('hwijew') driver.find_element_by_id('su').click() time.sleep(3) driver.quit()

控制台错误信息

Traceback (most recent call last): File "/selenium4.py", line 7, in <module> driver.get("http://www.google.com") File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 208, in check_response raise exception_class(value) selenium.common.exceptions.WebDriverException: Message: Host header or origin header is specified and is not localhost.

解决办法

  1. 重新下载selenium-server-standalone版本规定到3.141.1.jar, http://selenium-release.storage.googleapis.com/index.html?path=3.141/
  2. selenium版本锁定==3.141.0版本
  3. 使用教程参考博客:https://blog.csdn.net/hwijew/article/details/120548305

__EOF__

本文作者吹神
本文链接https://www.cnblogs.com/se7enjean/p/17022750.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   吹神  阅读(250)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
点击右上角即可分享
微信分享提示