Selenium:browser.visit(url) 在Linux失败但在Windows正常

0 投票
1 回答
530 浏览
提问于 2025-04-18 13:39

我在运行一个简单的脚本,这个脚本用到了selenium,主要是用来打开网页的。

在我的Windows电脑上,这个Python脚本运行得很好。但是在我的Linux服务器上,这个脚本就不行了。它在执行到上面的那行代码时就会立刻停止,并且崩溃。

  File "<stdin>", line 1, in <module>
  File "test.py", line 57, in run
    browser.visit(url)
  File "/usr/local/lib/python2.7/dist-packages/splinter/driver/webdriver/__init__.py", line 53, in visit
    self.connect(url)
  File "/usr/local/lib/python2.7/dist-packages/splinter/request_handler/request_handler.py", line 23, in connect
    self._create_connection()
  File "/usr/local/lib/python2.7/dist-packages/splinter/request_handler/request_handler.py", line 48, in _create_connection
    self.conn = http_client.HTTPConnection(self.host, self.port)
  File "/usr/lib/python2.7/httplib.py", line 693, in __init__
    self._set_hostport(host, port)
  File "/usr/lib/python2.7/httplib.py", line 712, in _set_hostport
    i = host.rfind(':')
AttributeError: 'NoneType' object has no attribute 'rfind'

1 个回答

2

(这个回答只是为了结束这个问题。)

你使用的是:

http:/

在你的 browser.visit 方法里面……你忘记加结束的斜杠了!

http://

撰写回答