Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- homebridge
- raspberry pi
- 나스닥
- 공모주
- Espressif
- 매터
- 파이썬
- MQTT
- 티스토리챌린지
- 애플
- 배당
- 홈네트워크
- cluster
- 현대통신
- Home Assistant
- Bestin
- 미국주식
- esp32
- 힐스테이트 광교산
- 오블완
- SK텔레콤
- Python
- ConnectedHomeIP
- 코스피
- 국내주식
- 해외주식
- RS-485
- matter
- 월패드
- Apple
Archives
- Today
- Total
YOGYUI
Pyppeteer - Chromium 다운로드 시 SSLCertVerificationError 발생할 경우 본문
반응형
맥북에서 Pyppeteer 패키지 (Headless chrome/chromium automation library)로 웹브라우저 크롤링 작업을 좀 하려했는데 오류가 발생했다
[예시 코드]
import asyncio
from pyppeteer import launch
async def main():
browser = await launch()
page = await browser.newPage()
await page.goto('http://www.google.com')
await browser.close()
asyncio.get_event_loop().run_until_complete(main())
[오류 발생]
[W:pyppeteer.chromium_downloader] Starting Chromium download. Download may take a few minutes.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1010, in _validate_conn
conn.connect()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/connection.py", line 411, in connect
self.sock = ssl_wrap_socket(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/util/ssl_.py", line 428, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/util/ssl_.py", line 472, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 1040, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "requests_html_test.py", line 5, in <module>
response.html.render()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/requests_html.py", line 586, in render
self.browser = self.session.browser # Automatically create a event loop and browser
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/requests_html.py", line 730, in browser
self._browser = self.loop.run_until_complete(super().browser)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/requests_html.py", line 714, in browser
self._browser = await pyppeteer.launch(ignoreHTTPSErrors=not(self.verify), headless=True, args=self.__browser_args)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyppeteer/launcher.py", line 307, in launch
return await Launcher(options, **kwargs).launch()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyppeteer/launcher.py", line 120, in __init__
download_chromium()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyppeteer/chromium_downloader.py", line 139, in download_chromium
extract_zip(download_zip(get_url()), DOWNLOADS_FOLDER / REVISION)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyppeteer/chromium_downloader.py", line 81, in download_zip
r = http.request('GET', url, preload_content=False)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/request.py", line 74, in request
return self.request_encode_url(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/request.py", line 96, in request_encode_url
return self.urlopen(method, url, **extra_kw)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/poolmanager.py", line 375, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 783, in urlopen
return self.urlopen(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 783, in urlopen
return self.urlopen(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 783, in urlopen
return self.urlopen(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/util/retry.py", line 573, 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/Mac/588429/chrome-mac.zip (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)')))
urllib3 패키지에서 SSLCertVerificationError 예외가 발생했다
권한 문제인가 싶어서 sudo로 실행해봐도 동일하길래 구글링을 좀 해봤다
[ 해결 ] urllib3 버전 문제
urllib3 패키지 버전이 1.25 미만이어야 제대로 돌아간다고 해서 새로 설치했다
(기존에 1.26.2 버전이 설치되어 있었다)
pip install -U "urllib3<1.25"
스크립트를 다시 실행해보니
[W:pyppeteer.chromium_downloader] Starting Chromium download. Download may take a few minutes.
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/connectionpool.py:842: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
warnings.warn((
100%|██████████| 86.8M/86.8M [00:02<00:00, 42.7Mb/s]
[W:pyppeteer.chromium_downloader] Chromium download done.
[W:pyppeteer.chromium_downloader] chromium extracted to: /Library/Application Support/pyppeteer/local-chromium/588429
다운로드가 제대로 완료되었다 (구현한 기능도 제대로 돌아간다 ㅎㅎ)
끝~!
[참고]
https://github.com/miyakogi/pyppeteer/issues/219
반응형
'Software > Python' 카테고리의 다른 글
PyQt5 - QSpinBox 0x7FFFFFFFF 이상 최대값으로 설정하기 (0) | 2022.02.08 |
---|---|
Python::typing::Literal - 변수값 범위 명시 (2) | 2022.01.24 |
2022년 공휴일을 알아보자 (feat. 공공데이터포털) (0) | 2021.12.22 |
pandas - 중복된 요소 넘버링하기 (0) | 2021.12.15 |
pandas - 데이터프레임 데이터형(dtype) 확인 (0) | 2021.09.21 |