Webスクレイピングを行う際に、沢山のエラーが出力されます。原因は何でしょうか?
pipで何かのパッケージをインストールしてないことが原因ですかね?
教えてください。
python
1import urllib.request 2from bs4 import BeautifulSoup 3 4class Scraper: 5 def __init__(self,site): 6 self.site = site 7 8 def scrape(self): 9 r = urllib.request.urlopen(self.site) 10 sp = BeautifulSoup(r.read(),"html.parser") 11 12 for tag in sp.find_all("a"): 13 print(tag.get("href")) 14 15news = "https://news.google.com/" 16Scraper(news).scrape()
python
1Traceback (most recent call last): 2 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1317, in do_open 3 encode_chunked=req.has_header('Transfer-encoding')) 4 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1229, in request 5 self._send_request(method, url, body, headers, encode_chunked) 6 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1275, in _send_request 7 self.endheaders(body, encode_chunked=encode_chunked) 8 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1224, in endheaders 9 self._send_output(message_body, encode_chunked=encode_chunked) 10 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1016, in _send_output 11 self.send(msg) 12 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 956, in send 13 self.connect() 14 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1392, in connect 15 server_hostname=server_hostname) 16 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 412, in wrap_socket 17 session=session 18 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 853, in _create 19 self.do_handshake() 20 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 1117, in do_handshake 21 self._sslobj.do_handshake() 22ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1051) 23 24During handling of the above exception, another exception occurred:
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/24 12:56
2018/11/24 13:36