반응형
문제: 크롤링에서 urllib.request.urlopen() 이 동작하지 않습니다. 아래는 해당 오류 메세지 입니다.
Traceback (most recent call last):
File "/Users/hyojin/Documents/git/mushroom/crawling/img_crawling.py", line 13, in <module>
html = urlopen(url)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 525, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 542, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1362, in https_open
return self.do_open(http.client.HTTPSConnection, req,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1322, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)>
해결: SSL 인증 모듈을 사용합니다. 아래의 모듈과 코드를 추가합니다.
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
// 기존 코드
반응형
'Error' 카테고리의 다른 글
[Android] Porting error (0) | 2021.01.20 |
---|---|
[MYSQL] Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually. (0) | 2020.05.14 |
[MYSQL] Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (0) | 2020.05.14 |
[JAVA] int 자료형이 클 때 해결법 (0) | 2020.05.13 |