pytube 中的 HTTP Error404

HTTP Error404 in pytube

它应该是一个 youtube 下载器,但每当我尝试 运行 我得到的代码是“urllib.error.HTTPError:HTTP 错误 404:未找到”,即使使用的 url/link 是一个可用任何浏览器打开的有效 url/link。 ide 使用:pycharm v2021.1.3 & pytube v10.9.3

from pytube import YouTube
link = input("Enter Link Here : ")
url = YouTube(link)
print("Downloading....")
video = url.streams.first()
video.download()
print("Downloaded")

#备用代码

from pytube import YouTube

link = input("Enter Youtube URL : ")
yt = YouTube(link)
videos = yt.streams.all()
# this will stream all the format available for the video
video = list(enumerate(videos))
# this will be index all the format in list starting with zero
for i in video:
    print(i)
    # this will print all the available format of video with proper index
print("Enter the desired option to download the format")
dn_option = int(input("Enter the option : "))
# ask user that which format he want to download
dn_video = videos[dn_option]
dn_video.download()
# for downloading the video
print("Downloaded successfully")

我的错误已经解决,是 pytube 模块出错了如果有人看到任何代码出现 HTTP 错误,请使用 2 个测试用例:

正确检查Link 重新安装 pytube(如果 pytube 不起作用安装 pytube3 但在卸载 pytube 之后) 谢谢大家!