【发布时间】:2021-10-01 15:17:19
【问题描述】:
它应该是一个 youtube 下载器,但每当我尝试运行代码时,我都会得到“urllib.error.HTTPError: HTTP Error 404: Not Found”,即使使用的 url/链接是可打开的有效 url/链接使用任何浏览器。使用的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")
【问题讨论】:
-
可以分享一下网址吗?
-
youtu.be/arQySiQLsbw m.youtube.com/watch?v=arQySiQLsbw(同一视频的不同链接)我什至尝试了不同视频的多个视频链接,但对我不起作用
-
这是 pytube 的一个错误,它以前发生过并已修复,但看起来它可能已被重新引入
-
您可以随时查看另一个库,例如youtube_dl 或 ytpy
-
youtube_dl是一个很好的选择,因为pytube知道这个反复出现的问题。
标签: python python-3.x youtube urllib3 pytube