티스토리 뷰
Scraping: SSL: http://en.wikipedia.org에 대한 SSL: CERTIFICATE_VERIFI_FAILED 오류
맨날치킨 2022. 11. 27. 23:05Stack Overflow에 자주 검색, 등록되는 문제들과 제가 개발 중 찾아 본 문제들 중에서 나중에도 찾아 볼 것 같은 문제들을 정리하고 있습니다.
Stack Overflow에서 가장 먼저 확인하게 되는 가장 높은 점수를 받은 Solution과 현 시점에 도움이 될 수 있는 가장 최근에 업데이트(최소 점수 확보)된 Solution을 각각 정리하였습니다.
아래 word cloud를 통해 이번 포스팅의 주요 키워드를 미리 확인하세요.
Scraping: SSL: CERTIFICATE_VERIFY_FAILED error for http://en.wikipedia.org
Scraping: SSL: http://en.wikipedia.org에 대한 SSL: CERTIFICATE_VERIFI_FAILED 오류
문제 내용
I'm practicing the code from 'Web Scraping with Python', and I keep having this certificate problem:
나는 'Web Scraping with Python'의 코드를 연습하고 있는데, 계속해서 다음과 같은 인증서 문제가 발생한다.
from urllib.request import urlopen
from bs4 import BeautifulSoup
import re
pages = set()
def getLinks(pageUrl):
global pages
html = urlopen("http://en.wikipedia.org"+pageUrl)
bsObj = BeautifulSoup(html)
for link in bsObj.findAll("a", href=re.compile("^(/wiki/)")):
if 'href' in link.attrs:
if link.attrs['href'] not in pages:
#We have encountered a new page
newPage = link.attrs['href']
print(newPage)
pages.add(newPage)
getLinks(newPage)
getLinks("")
The error is:
오류는 다음과 같습니다.
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1319, 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:1049)>
Btw,I was also practicing scrapy, but kept getting the problem: command not found: scrapy (I tried all sorts of solutions online but none works... really frustrating)
그나저나, 나도 스크래피 연습을 하고 있었는데 계속 문제가 생겼어: 명령어를 찾을 수 없어: 스크래피 (온라인에서 모든 종류의 해결책을 시도했지만 아무 소용이 없었어... 정말 짜증나)
높은 점수를 받은 Solution
Once upon a time I stumbled with this issue. If you're using macOS go to Macintosh HD > Applications > Python3.6 folder (or whatever version of python you're using) > double click on "Install Certificates.command" file. :D
옛날에 나는 이 문제로 비틀거렸다. MacOS를 사용하는 경우 Macintosh HD > Applications > Python 3.6 폴더(또는 사용 중인 파이썬 버전) > "Install Certificates.command" 파일을 두 번 클릭합니다. :D
가장 최근 달린 Solution
open /Applications/Python\ 3.7/Install\ Certificates.command
Try this command in terminal
터미널에서 이 명령 사용
출처 : https://stackoverflow.com/questions/50236117/scraping-ssl-certificate-verify-failed-error-for-http-en-wikipedia-org
'개발 > 파이썬' 카테고리의 다른 글
ImportError: 'django.core.urlresolvers'라는 모듈이 없습니다. (0) | 2022.11.28 |
---|---|
동적으로 가져온 모듈에서 동적 인스턴스 생성하기 (0) | 2022.11.28 |
가져오기 오류: sklearn.cross_validation이라는 모듈이 없습니다. (0) | 2022.11.27 |
python 멀티프로세싱 시도하는 중 Windows에서 런타임 오류 (0) | 2022.11.27 |
pytest는 모듈을 가져올 수 없지만 python은 가져올 수 있음 (0) | 2022.11.27 |