Так как мне нужно посетить учетные данные Google листа через VPN.Поэтому я создал носки для посещения через VPN «localhost: 1086».
Затем я создал webdriver-selenium для открытия URL-адреса, который успешно работает без запуска носков.Но после установки носков я получил ОШИБКУ «RemoteDisconnected: удаленное соединение закрыто без ответа».
Я подумал, могу ли я что-нибудь сделать, чтобы вернуть носки в нормальное состояние и как их установить.Спасибо.
Я уверен, что это не просто ошибка протокола, что без настройки носков, веб-драйвер работает довольно хорошо.
Для настройки носков:
import socks
socks.set_default_proxy(socks.SOCKS5, "localhost", 1086)
import socket
socket.socket = socks.socksocket
Для веб-драйвера:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('https://review-api.udacity.com/admin/submission')
Ошибка
---------------------------------------------------------------------------
RemoteDisconnected Traceback (most recent call last)
~/miniconda3/envs/udacity/lib/python3.6/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
599 body=body, headers=headers,
--> 600 chunked=chunked)
601
~/miniconda3/envs/udacity/lib/python3.6/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
383 # otherwise it looks like a programming error was the cause.
--> 384 six.raise_from(e, None)
385 except (SocketTimeout, BaseSSLError, SocketError) as e:
~/miniconda3/envs/udacity/lib/python3.6/site-packages/urllib3/packages/six.py in raise_from(value, from_value)
~/miniconda3/envs/udacity/lib/python3.6/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
379 try:
--> 380 httplib_response = conn.getresponse()
381 except Exception as e:
~/miniconda3/envs/udacity/lib/python3.6/http/client.py in getresponse(self)
1330 try:
-> 1331 response.begin()
1332 except ConnectionError:
~/miniconda3/envs/udacity/lib/python3.6/http/client.py in begin(self)
296 while True:
--> 297 version, status, reason = self._read_status()
298 if status != CONTINUE:
~/miniconda3/envs/udacity/lib/python3.6/http/client.py in _read_status(self)
265 # sending a valid response.
--> 266 raise RemoteDisconnected("Remote end closed connection without"
267 " response")
RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
ProtocolError Traceback (most recent call last)
~/miniconda3/envs/udacity/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py in __init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options, keep_alive)
80 keep_alive=keep_alive),
---> 81 desired_capabilities=desired_capabilities)
82 except Exception:
~/miniconda3/envs/udacity/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py in __init__(self, command_executor, desired_capabilities, browser_profile, proxy, keep_alive, file_detector, options)
156 DeprecationWarning, stacklevel=2)
--> 157 self.start_session(capabilities, browser_profile)
158 self._switch_to = SwitchTo(self)
~/miniconda3/envs/udacity/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py in start_session(self, capabilities, browser_profile)
251 "desiredCapabilities": capabilities}
--> 252 response = self.execute(Command.NEW_SESSION, parameters)
253 if 'sessionId' not in response:
~/miniconda3/envs/udacity/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py in execute(self, driver_command, params)
318 params = self._wrap_value(params)
--> 319 response = self.command_executor.execute(driver_command, params)
320 if response:
~/miniconda3/envs/udacity/lib/python3.6/site-packages/selenium/webdriver/remote/remote_connection.py in execute(self, command, params)
373 url = '%s%s' % (self._url, path)
--> 374 return self._request(command_info[0], url, body=data)
375
~/miniconda3/envs/udacity/lib/python3.6/site-packages/selenium/webdriver/remote/remote_connection.py in _request(self, method, url, body)
396 if self.keep_alive:
--> 397 resp = self._conn.request(method, url, body=body, headers=headers)
398
~/miniconda3/envs/udacity/lib/python3.6/site-packages/urllib3/request.py in request(self, method, url, fields, headers, **urlopen_kw)
71 headers=headers,
---> 72 **urlopen_kw)
73
~/miniconda3/envs/udacity/lib/python3.6/site-packages/urllib3/request.py in request_encode_body(self, method, url, fields, headers, encode_multipart, multipart_boundary, **urlopen_kw)
149
--> 150 return self.urlopen(method, url, **extra_kw)
~/miniconda3/envs/udacity/lib/python3.6/site-packages/urllib3/poolmanager.py in urlopen(self, method, url, redirect, **kw)
322 else:
--> 323 response = conn.urlopen(method, u.request_uri, **kw)
324
~/miniconda3/envs/udacity/lib/python3.6/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
637 retries = retries.increment(method, url, error=e, _pool=self,
--> 638 _stacktrace=sys.exc_info()[2])
639 retries.sleep()
~/miniconda3/envs/udacity/lib/python3.6/site-packages/urllib3/util/retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
366 if read is False or not self._is_method_retryable(method):
--> 367 raise six.reraise(type(error), error, _stacktrace)
368 elif read is not None:
~/miniconda3/envs/udacity/lib/python3.6/site-packages/urllib3/packages/six.py in reraise(tp, value, tb)
684 if value.__traceback__ is not tb:
--> 685 raise value.with_traceback(tb)
686 raise value
~/miniconda3/envs/udacity/lib/python3.6/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
599 body=body, headers=headers,
--> 600 chunked=chunked)
601
~/miniconda3/envs/udacity/lib/python3.6/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
383 # otherwise it looks like a programming error was the cause.
--> 384 six.raise_from(e, None)
385 except (SocketTimeout, BaseSSLError, SocketError) as e:
~/miniconda3/envs/udacity/lib/python3.6/site-packages/urllib3/packages/six.py in raise_from(value, from_value)
~/miniconda3/envs/udacity/lib/python3.6/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
379 try:
--> 380 httplib_response = conn.getresponse()
381 except Exception as e:
~/miniconda3/envs/udacity/lib/python3.6/http/client.py in getresponse(self)
1330 try:
-> 1331 response.begin()
1332 except ConnectionError:
~/miniconda3/envs/udacity/lib/python3.6/http/client.py in begin(self)
296 while True:
--> 297 version, status, reason = self._read_status()
298 if status != CONTINUE:
~/miniconda3/envs/udacity/lib/python3.6/http/client.py in _read_status(self)
265 # sending a valid response.
--> 266 raise RemoteDisconnected("Remote end closed connection without"
267 " response")
ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
During handling of the above exception, another exception occurred:
RemoteDisconnected Traceback (most recent call last)
<ipython-input-28-c04a71e05f66> in <module>
12 if not reviews[i]['Auto-processing']:
13 e = reviews[i]['Email']
---> 14 results = process(e)
15 print(results)
cell_name in process(e)
~/miniconda3/envs/udacity/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py in __init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options, keep_alive)
81 desired_capabilities=desired_capabilities)
82 except Exception:
---> 83 self.quit()
84 raise
85 self._is_remote = False
~/miniconda3/envs/udacity/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py in quit(self)
156 pass
157 finally:
--> 158 self.service.stop()
159
160 def create_options(self):
~/miniconda3/envs/udacity/lib/python3.6/site-packages/selenium/webdriver/common/service.py in stop(self)
149
150 try:
--> 151 self.send_remote_shutdown_command()
152 except TypeError:
153 pass
~/miniconda3/envs/udacity/lib/python3.6/site-packages/selenium/webdriver/common/service.py in send_remote_shutdown_command(self)
125
126 try:
--> 127 url_request.urlopen("%s/shutdown" % self.service_url)
128 except URLError:
129 return
~/miniconda3/envs/udacity/lib/python3.6/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
221 else:
222 opener = _opener
--> 223 return opener.open(url, data, timeout)
224
225 def install_opener(opener):
~/miniconda3/envs/udacity/lib/python3.6/urllib/request.py in open(self, fullurl, data, timeout)
524 req = meth(req)
525
--> 526 response = self._open(req, data)
527
528 # post-process response
~/miniconda3/envs/udacity/lib/python3.6/urllib/request.py in _open(self, req, data)
542 protocol = req.type
543 result = self._call_chain(self.handle_open, protocol, protocol +
--> 544 '_open', req)
545 if result:
546 return result
~/miniconda3/envs/udacity/lib/python3.6/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
502 for handler in handlers:
503 func = getattr(handler, meth_name)
--> 504 result = func(*args)
505 if result is not None:
506 return result
~/miniconda3/envs/udacity/lib/python3.6/urllib/request.py in http_open(self, req)
1344
1345 def http_open(self, req):
-> 1346 return self.do_open(http.client.HTTPConnection, req)
1347
1348 http_request = AbstractHTTPHandler.do_request_
~/miniconda3/envs/udacity/lib/python3.6/urllib/request.py in do_open(self, http_class, req, **http_conn_args)
1319 except OSError as err: # timeout error
1320 raise URLError(err)
-> 1321 r = h.getresponse()
1322 except:
1323 h.close()
~/miniconda3/envs/udacity/lib/python3.6/http/client.py in getresponse(self)
1329 try:
1330 try:
-> 1331 response.begin()
1332 except ConnectionError:
1333 self.close()
~/miniconda3/envs/udacity/lib/python3.6/http/client.py in begin(self)
295 # read until we get a non-100 response
296 while True:
--> 297 version, status, reason = self._read_status()
298 if status != CONTINUE:
299 break
~/miniconda3/envs/udacity/lib/python3.6/http/client.py in _read_status(self)
264 # Presumably, the server closed the connection before
265 # sending a valid response.
--> 266 raise RemoteDisconnected("Remote end closed connection without"
267 " response")
268 try:
RemoteDisconnected: Remote end closed connection without response