파이썬

파이썬 웹크롤링 오류 대처방법(verify=False)requests.exceptions.SSLError:

by nanumi posted Sep 16, 2021
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄

파이썬 웹크롤링 오류 대처방법

 

requests.exceptions.SSLError: HTTPSConnectionPool(host='www.khnp.co.kr', port=443): Max retries exceeded with url: /RECU_NEW/RECU_NEW?cmdn=NEW_BQ10 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: 

CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)')))

 

 

계속 오류가 발생하여

requests에 

verify=False

넣어주니 정상 출력됩니다.

 

 

#https://www.khnp.co.kr/RECU_NEW/RECU_NEW?cmdn=NEW_BQ10
url = "https://www.khnp.co.kr/RECU_NEW/RECU_NEW?cmdn=NEW_BQ10"
headers = {
    'Accept''text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
    'Accept-Encoding''gzip, deflate, br',
    'Accept-Language''ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7',
    'Cache-Control''max-age=0',
    'Connection''keep-alive',
    'Cookie''_ga=GA1.3.1345281943.1598146999; WCN_KHNPHOME=QkrtkGFs0nLNfj768SbVmQxr1OIQpvJie6TiuEk3bu84v_vPDIa-!-1184041201; _gid=GA1.3.270150670.1631778271; WCN_RECU_NEW=nKTtlGf4CrAf9URFkArymhC8ylIFHyv1pMWEmGfcEosfnWqQDFJh!-681835361',
    'Host''www.khnp.co.kr',
    'Referer''https://search.naver.com/search.naver?where=nexearch&sm=top_hty&fbm=1&ie=utf8&query=%ED%95%9C%EC%88%98%EC%9B%90+%EC%B1%84%EC%9A%A9',
    'User-Agent''Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.3'
    }
html = requests.get(urlheaders=headers,verify=False)  
bs_html = BeautifulSoup(html.content,"html.parser")
 
temp = bs_html.find("tbody")
print(temp)