docker - Chromedriver:Chrome 连接因 Docker 容器中的硒而失败
问题描述
我想运行下面的代码并使用 selenium 连接到 chrome。我在 PATH 中安装并chromium-browser
安装了 chromedriver 91.0.4472.101。我错过了要安装的东西吗?是访问 id/pw 错误吗?任何提示将不胜感激。
编码:
@retry(tries=4, delay=2, backoff=2,exceptions=(RetryException))
def oneTry(self,fromd,tod,exit=0):
try :
self.openSearchPage()
self.prep(fromd.strftime("%d/%m/%Y"),tod.strftime("%d/%m/%Y"),exit)
self.searchClick()
self.checkTableHTML()
fromdstr = fromd.strftime("%Y/%m/%d")
todstr = tod.strftime("%Y/%m/%d")
print("[ from: {} - to: {} ]".format(fromdstr,todstr), end=" => ")
self.waitLoading()
self.buttonClick()
# time.sleep(random.uniform(20,120))
time.sleep(2)
filedf = pd.DataFrame([[x.name,datetime.fromtimestamp(x.stat().st_ctime)] for x in self.path.glob("*.xls")],columns=["name","timestamp"])
filedf = filedf.sort_values(["timestamp"],ascending=False).reset_index(drop=True)
tmppath = Path(filedf.name[0])
tmppath.rename("DOWN_{}_{}_{}.xls".format(datetime.now().strftime("%Y%m%d_%H%M%S"),fromdstr.replace("/","-"),todstr.replace("/","-")))
except Exception as e :
print(e.args)
print(".... FAIL ... |")
raise RetryException
错误:
ConnectionRefusedError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/urllib3/connection.py in _new_conn(self)
169 conn = connection.create_connection(
--> 170 (self._dns_host, self.port), self.timeout, **extra_kw
/usr/local/lib/python3.6/dist-packages/urllib3/util/connection.py in create_connection(address, timeout, source_address, socket_options)
85 sock.bind(source_address)
---> 86 sock.connect(sa)
87 return sock
ConnectionRefusedError: [Errno 111] Connection refused
...
/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
393 else:
--> 394 conn.request(method, url, **httplib_request_kw)
/usr/local/lib/python3.6/dist-packages/urllib3/connection.py in request(self, method, url, body, headers)
233 headers["User-Agent"] = _get_default_user_agent()
--> 234 super(HTTPConnection, self).request(method, url, body=body, headers=headers)
/usr/lib/python3.6/http/client.py in request(self, method, url, body, headers, encode_chunked)
1280 """Send a complete request to the server."""
-> 1281 self._send_request(method, url, body, headers, encode_chunked)
/usr/lib/python3.6/http/client.py in _send_request(self, method, url, body, headers, encode_chunked)
1326 body = _encode(body, 'body')
-> 1327 self.endheaders(body, encode_chunked=encode_chunked)
/usr/local/lib/python3.6/dist-packages/urllib3/connection.py in connect(self)
199 def connect(self):
--> 200 conn = self._new_conn()
201 self._prepare_conn(conn)
/usr/local/lib/python3.6/dist-packages/urllib3/connection.py in _new_conn(self)
181 raise NewConnectionError(
--> 182 self, "Failed to establish a new connection: %s" % e
NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f76487e2b38>: Failed to establish a new connection: [Errno 111] Connection refused
解决方案
推荐阅读
- javascript - 使用javascript滚动窗口后如何修复顶部的按钮?
- android - 使用 rxjava 定时器和改造
- python-2.7 - 提取检测到的类名——tensorflow对象检测API
- sql-server - 一个 M 查询依赖于来自并行 M 查询的数据
- php - 使用 Laravel 的 XML 解析器 orchesta/解析器中的多个值
- angular - 从订阅全局角度5制作api数据
- python - 如何从请求中获取 django rest 框架中的发布对象
- html - 居中并使图像越过屏幕边缘 - Ionic
- vba - Excel 遍历 2 张纸中的行并捕获特定行上的数据
- java - Apache Flink CEP如何检测事件是否在x秒内没有发生?