Python3でpytubeがうまく動作しません。
python
1from pytube import YouTube 2 3url = input() 4yt = YouTube(url) 5print(yt.title) 6コード
URLにYouTubeのURLを代入してこのコードで実行するとエラーが出ます。
pytubeは8.02です。
どうすれば動くようになりますか?
Python
1 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1318, in do_open 2 encode_chunked=req.has_header('Transfer-encoding')) 3 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1239, in request 4 self._send_request(method, url, body, headers, encode_chunked) 5 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1285, in _send_request 6 self.endheaders(body, encode_chunked=encode_chunked) 7 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1234, in endheaders 8 self._send_output(message_body, encode_chunked=encode_chunked) 9 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1026, in _send_output 10 self.send(msg) 11 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 964, in send 12 self.connect() 13 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1400, in connect 14 server_hostname=server_hostname) 15 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 407, in wrap_socket 16 _context=self, _session=session) 17 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 814, in __init__ 18 self.do_handshake() 19 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 1068, in do_handshake 20 self._sslobj.do_handshake() 21 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 689, in do_handshake 22 self._sslobj.do_handshake() 23ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777) 24 25During handling of the above exception, another exception occurred: 26 27Traceback (most recent call last): 28 File "<pyshell#6>", line 1, in <module> 29 yt = YouTube(url) 30 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pytube/__main__.py", line 83, in __init__ 31 self.prefetch_init() 32 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pytube/__main__.py", line 91, in prefetch_init 33 self.prefetch() 34 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pytube/__main__.py", line 147, in prefetch 35 self.watch_html = request.get(url=self.watch_url) 36 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pytube/request.py", line 21, in get 37 response = urlopen(url) 38 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen 39 return opener.open(url, data, timeout) 40 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 526, in open 41 response = self._open(req, data) 42 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 544, in _open 43 '_open', req) 44 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain 45 result = func(*args) 46 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1361, in https_open 47 context=self._context, check_hostname=self._check_hostname) 48 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1320, in do_open 49 raise URLError(err) 50urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)> 51コード
回答2件
あなたの回答
tips
プレビュー