Pytube错误:urllib.error.HTTPError:HTTP错误404:未找到

2024-04-20 05:04:25 发布

您现在位置:Python中文网/ 问答频道 /正文


from pytube import YouTube

url = 'https://youtu.be/7hvcJK5-OLI'
my_video = YouTube(url)

print("=================== Video Title ====================")
print(my_video.title)                                             # This prints the title of the youtube video

print("=================== Thumbnail Image ====================")
print(my_video.thumbnail_url)                                     # This prints the thumbnail link in terminal

print("=================== Download Video ====================")

choise = input("Do you want to download mp3 or mp4: ")

if choise.lower() == 'mp4':
    my_video = my_video.streams.get_highest_resolution()          # We set the resolusion of the video

elif choise.lower() == 'mp3':
    my_video = my_video.streams.get_audio_only()                  # To get only audio we set this

else:
    print("Invalid option! ")
    exit()

my_video.download()

这是我的密码。我试图为这个项目制作一个简单的youtube下载程序,但它不断抛出HTTP错误:404,尽管我的url都是正确的


Tags: oftheurlgettitleyoutubemyvideo