擅长:python、mysql、java
<p>在python 3.x中从youtube下载视频
对于参考,您可以检查<a href="https://python-pytube.readthedocs.io/en/latest/user/quickstart.html#downloading-a-video" rel="noreferrer">https://python-pytube.readthedocs.io/en/latest/user/quickstart.html#downloading-a-video</a></p>
<pre><code>from pytube import YouTube
import os
def downloadYouTube(videourl, path):
yt = YouTube(videourl)
yt = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first()
if not os.path.exists(path):
os.makedirs(path)
yt.download(path)
downloadYouTube('https://www.youtube.com/watch?v=zNyYDHCg06c', './videos/FindingNemo1')
</code></pre>