5 글 보임 - 1 에서 5 까지 (총 5 중에서)
-
글쓴이글
-
2022년 7월 9일 07:54 #38318
김동하참가자from selenium import webdriver; from selenium.webdriver.common.keys import Keys; import requests driver = webdriver.Chrome('/Users/dongha0917/python/chromedriver'); driver.implicitly_wait(10) driver.get('https://www.google.com/imghp') q = driver.find_element_by_css_selector('input[name="q"]') q.send_keys("사과"); q.send_keys(Keys.ENTER); sel = driver.find_elements_by_class_name('wXeWr')[0] sel.click(); img = driver.find_element_by_css_selector('img.KAlRDb'); img_url = img.get_attribute('src'); file_name = "1." + img_url.split('.')[-1]; img_data = requests.get(img_url) f = open(file_name, 'wb'); f.write(img_data.content) 코드는 구글 이미지검색에서 사과 검색하고 첫번쨰 사진눌러서 큰사진의링크를 얻고 저장하는 코드가목적입니다. 하지만 urlretrieve를 사용해도 되지않습니다 검색했는데도 해결방법을 정말많이 시도하였스나 해결이되지않아 질문드립니다
/usr/local/bin/python3 /Users/dongha0917/python/app.py Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1348, in do_open h.request(req.get_method(), req.selector, req.data, headers, File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1282, in request self._send_request(method, url, body, headers, encode_chunked) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1328, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1277, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1037, in _send_output self.send(msg) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 975, in send self.connect() File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1454, in connect self.sock = self._context.wrap_socket(self.sock, File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 513, in wrap_socket return self.sslsocket_class._create( File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1071, in _create self.do_handshake() File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1342, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/Users/dongha0917/python/app.py", line 15, in <module> urllib.request.urlretrieve(img_url, file_name) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 241, in urlretrieve with contextlib.closing(urlopen(url, data)) as fp: File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 216, in urlopen return opener.open(url, data, timeout) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 519, in open response = self._open(req, data) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 536, in _open result = self._call_chain(self.handle_open, protocol, protocol + File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 496, in _call_chain result = func(*args) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1391, in https_open return self.do_open(http.client.HTTPSConnection, req, File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1351, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)>
2022년 7월 9일 14:54 #38336
codingapple키 마스터파이썬 설치시 python.org에서 다운받아서 설치하셨나요 아니면 이런거 따라합시다 https://stackoverflow.com/questions/68275857/urllib-error-urlerror-urlopen-error-ssl-certificate-verify-failed-certifica
2022년 7월 10일 12:56 #38376
codingapple키 마스터ssl이나 certifi 패키지 설치해봅시다 https://exerror.com/urllib-error-urlerror-urlopen-error-ssl-certificate_verify_failed-certificate-verify-failed-unable-to-get-local-issuer-certificate/#:~:text=error.-,URLError%3A%20urlopen%20error%20%5BSSL%3A%20CERTIFICATE_VERIFY_FAILED%5D%20certificate%20verify%20failed,Then%20Select%20Python%20folder%20(%20Python3.
-
글쓴이글
5 글 보임 - 1 에서 5 까지 (총 5 중에서)
- 답변은 로그인 후 가능합니다.