我刚刚开始研究硒。但我一直在遇到这个问题
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 248, in get
self.execute(Command.GET, {'url': url})
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 234, in execute
response = self.command_executor.execute(driver_command, params)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/remote_connection.py", line 401, in execute
return self._request(command_info[0], url, body=data)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/remote_connection.py", line 431, in _request
self._conn.request(method, parsed_url.path, body, headers)
File "/usr/lib/python3.5/http/client.py", line 1106, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python3.5/http/client.py", line 1151, in _send_request
self.endheaders(body)
File "/usr/lib/python3.5/http/client.py", line 1102, in endheaders
self._send_output(message_body)
File "/usr/lib/python3.5/http/client.py", line 934, in _send_output
self.send(msg)
File "/usr/lib/python3.5/http/client.py", line 877, in send
self.connect()
File "/usr/lib/python3.5/http/client.py", line 849, in connect
(self.host,self.port), self.timeout, self.source_address)
File "/usr/lib/python3.5/socket.py", line 711, in create_connection
raise err
File "/usr/lib/python3.5/socket.py", line 702, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
我确实尝试在网上搜索。 我的selenium和Firefox版本是最新版本。 因为它只是一个开始,我从互联网上有一个简单的三行,并试图运行它。
>>> from selenium import webdriver
>>> br = webdriver.Firefox()
>>> br.implicitly_wait(15)
>>> br.get('http://youtube.com')
答案 0 :(得分:0)
确保您拥有最新版本的firefox浏览器&amp; geckodriver。
要安装最新的壁虎,请按照以下步骤操作:
查找最新版本的驱动程序:
wget https://github.com/mozilla/geckodriver/releases/download/v0.18.0/geckodriver-v0.18.0-arm7hf.tar.gz
使用tar -xvzf geckodriver*
使其可执行:chmod +x geckodriver
将驱动程序添加到PATH中,以便其他工具可以找到它:
export PATH=$PATH:/path-to-extracted-file/geckodriver