我想用 Python 下载 YouTube 视频。我用Python试过opencv,但是一直有问题。我正在尝试使用 pytube3 和 Python 3。我尝试了这个程序(我在StackOverflow 上找到的):
from pytube import YouTube
YouTube('http://youtube.com/watch?v=9bZkp7q19f0').streams.first().download()
Run Code Online (Sandbox Code Playgroud)
但它因“HTTP 错误 410”错误而失败。当我运行各种 pytube 程序时,我不断收到“HTTP 错误 410”。我更改了 URL 并在浏览器中测试了 URL。当我运行 Python 程序下载视频时,没有任何效果。
我正在尝试运行此程序(正如我在此处找到的那样):
from pytube import YouTube
try:
yt_obj = YouTube('https://www.youtube.com/watch?v=DkU9WFj8sYo')
print(f'Video Title is {yt_obj.title}')
print(f'Video Length is {yt_obj.length} seconds')
print(f'Video Description is {yt_obj.description}')
print(f'Video Rating is {yt_obj.rating}')
print(f'Video Views Count is {yt_obj.views}')
print(f'Video Author is {yt_obj.author}')
except Exception as e:
print(e)
Run Code Online (Sandbox Code Playgroud)
我懂了:
HTTP 错误 410:Gone Traceback(最近一次调用最后一次):文件“e.py”,第 9 行,在 yt_obj = …