pip3 install pyppeteer
pyppeteer-install
[simple@redhat_1 pyppetter]$ pyppeteer-install
[W:pyppeteer.chromium_downloader] start chromium download.
Download may take a few minutes.
Traceback (most recent call last):
File "/home/simple/.local/lib/python3.6/site-packages/urllib3/connection.py", line 159, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "/home/simple/.local/lib/python3.6/site-packages/urllib3/util/connection.py", line 80, in create_connection
raise err
File "/home/simple/.local/lib/python3.6/site-packages/urllib3/util/connection.py", line 70, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/simple/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/home/simple/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "/home/simple/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn
conn.connect()
File "/home/simple/.local/lib/python3.6/site-packages/urllib3/connection.py", line 301, in connect
conn = self._new_conn()
File "/home/simple/.local/lib/python3.6/site-packages/urllib3/connection.py", line 168, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/pyppeteer-install", line 11, in
sys.exit(install())
File "/usr/local/lib/python3.6/site-packages/pyppeteer/command.py", line 14, in install
download_chromium()
File "/usr/local/lib/python3.6/site-packages/pyppeteer/chromium_downloader.py", line 146, in download_chromium
extract_zip(download_zip(get_url()), DOWNLOADS_FOLDER / REVISION)
File "/usr/local/lib/python3.6/site-packages/pyppeteer/chromium_downloader.py", line 85, in download_zip
data = http.request('GET', url, preload_content=False)
File "/home/simple/.local/lib/python3.6/site-packages/urllib3/request.py", line 68, in request
**urlopen_kw)
File "/home/simple/.local/lib/python3.6/site-packages/urllib3/request.py", line 89, in request_encode_url
return self.urlopen(method, url, **extra_kw)
File "/home/simple/.local/lib/python3.6/site-packages/urllib3/poolmanager.py", line 324, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/home/simple/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 667, in urlopen
**response_kw)
File "/home/simple/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 667, in urlopen
**response_kw)
File "/home/simple/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 667, in urlopen
**response_kw)
File "/home/simple/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/home/simple/.local/lib/python3.6/site-packages/urllib3/util/retry.py", line 399, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='storage.googleapis.com', port=443): Max retries exceeded with url: /chromium-browser-snapshots/Linux_x64/588429/chrome-linux.zip (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused',))
解决办法
pip install -U "urllib3<1.25"
解决办法
import sys
import os
import pyppeteer.chromium_downloader
def current_platform() -> str:
"""Get current platform name by short string."""
if sys.platform.startswith('linux'):
return 'linux'
elif sys.platform.startswith('darwin'):
return 'mac'
elif (sys.platform.startswith('win') or
sys.platform.startswith('msys') or
sys.platform.startswith('cyg')):
if sys.maxsize > 2 ** 31 - 1:
return 'win64'
return 'win32'
raise OSError('Unsupported platform: ' + sys.platform)
platform = current_platform()
print('默认版本是:{}'.format(pyppeteer.__chromium_revision__))
print('平台下载链接为:{}'.format(pyppeteer.chromium_downloader.downloadURLs.get(platform)))
print('解压目录:{}'.format(
os.path.dirname(os.path.dirname(pyppeteer.chromium_downloader.chromiumExecutable.get(platform)))
))
获取到下载地址后,想办法通过其他方式把该文件下载下来即可。
下载文件后,解压到chromium文件默认路径
中。