简体   繁体   English

Python / Selenium:HTMLUNIT驱动程序连接被拒绝-端口被阻止

[英]Python/Selenium: HTMLUNIT Driver Connection Refused - Port Blocked

I am trying to set up and use HTMLUnit driver in Python 3. I believe I have the server running (v3.7.0) and believe the code should work based looking up other questions on here. 我正在尝试在Python 3中设置和使用HTMLUnit驱动程序。我相信我正在运行服务器(v3.7.0),并且我认为代码应该可以在这里查找其他问题来工作。 I believe that the remote server uses port 4444 but my ISP locks that port down (along with basically every other port). 我相信远程服务器使用端口4444,但是我的ISP锁定了该端口(以及几乎所有其他端口)。 Currently when I run the code I get a connection refused. 当前,当我运行代码时,连接被拒绝。 Is this to do with the port being closed? 这与关闭端口有关吗? Can I change the port to 8080 (which is open)? 我可以将端口更改为8080(已打开)吗?

from selenium import webdriver
driver = webdriver.Remote(desired_capabilities=webdriver.DesiredCapabilities.HTMLUNITWITHJS)
driver.get('http://www.google.com')

Current output: 电流输出:

urllib.error.URLError: <urlopen error [Errno 61] Connection refused>

From this Link : 从此链接

You can use: 您可以使用:

driver = webdriver.Remote("http://localhost:4444/wd/hub", webdriver.DesiredCapabilities.HTMLUNITWITHJS)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM