python初学者です。
seleniumを使ってスクレイピングを行いたいのですが、エラーが出てしまって困っております。
何か分かる方いたら、教えてくれるとありがたいです。
下記のコードを実行するとエラーが出ます。
python
1from selenium import webdriver 2 3options = webdriver.ChromeOptions() 4options.add_argument('--headless') 5driver = webdriver.Remote( 6 command_executor='http://localhost:4444/wd/hub', 7 desired_capabilities=options.to_capabilities(), 8 options=options 9)
こちらがエラーの内容です。
Traceback (most recent call last): File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/site-packages/urllib3/connection.py", line 170, in _new_conn (self._dns_host, self.port), self.timeout, **extra_kw File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/site-packages/urllib3/util/connection.py", line 96, in create_connection raise err File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/site-packages/urllib3/util/connection.py", line 86, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 61] Connection refused During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/site-packages/urllib3/connectionpool.py", line 706, in urlopen chunked=chunked, File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/site-packages/urllib3/connectionpool.py", line 394, in _make_request conn.request(method, url, **httplib_request_kw) File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/site-packages/urllib3/connection.py", line 234, in request super(HTTPConnection, self).request(method, url, body=body, headers=headers) File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/http/client.py", line 1239, in request self._send_request(method, url, body, headers, encode_chunked) File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/http/client.py", line 1285, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/http/client.py", line 1234, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/http/client.py", line 1026, in _send_output self.send(msg) File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/http/client.py", line 964, in send self.connect() File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/site-packages/urllib3/connection.py", line 200, in connect conn = self._new_conn() File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/site-packages/urllib3/connection.py", line 182, in _new_conn self, "Failed to establish a new connection: %s" % e urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x11196db38>: Failed to establish a new connection: [Errno 61] Connection refused During handling of the above exception, another exception occurred: Traceback (most recent call last): File "index.py", line 19, in <module> options=options File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__ self.start_session(capabilities, browser_profile) File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 319, in execute response = self.command_executor.execute(driver_command, params) File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/site-packages/selenium/webdriver/remote/remote_connection.py", line 374, in execute return self._request(command_info[0], url, body=data) File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/site-packages/selenium/webdriver/remote/remote_connection.py", line 402, in _request resp = http.request(method, url, body=body, headers=headers) File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/site-packages/urllib3/request.py", line 79, in request method, url, fields=fields, headers=headers, **urlopen_kw File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/site-packages/urllib3/request.py", line 170, in request_encode_body return self.urlopen(method, url, **extra_kw) File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/site-packages/urllib3/poolmanager.py", line 375, in urlopen response = conn.urlopen(method, u.request_uri, **kw) File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/site-packages/urllib3/connectionpool.py", line 796, in urlopen **response_kw File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/site-packages/urllib3/connectionpool.py", line 796, in urlopen **response_kw File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/site-packages/urllib3/connectionpool.py", line 796, in urlopen **response_kw File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/site-packages/urllib3/connectionpool.py", line 756, in urlopen method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2] File "/Users/muratariku/.pyenv/versions/3.6.0/lib/python3.6/site-packages/urllib3/util/retry.py", line 573, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=4444): Max retries exceeded with url: /wd/hub/session (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x11196db38>: Failed to establish a new connection: [Errno 61] Connection refused',))
過去にはスクレイピングに成功しており、今回いきなり、エラーとなってしまいました。
chromeとchromedriverのバージョンがあってるか確認しましたが、問題はありませんでした。
どなたか分かる方いましたらお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。