YouTube 下载器 HTTPError:HTTP 错误 404:未找到

时间:2021-07-28 09:52:55

标签: python http error-handling pytube

我的代码昨天可以运行,但是当我尝试运行它时出现错误

from pytube import YouTube

#ask for the link from user
link = input("Enter the link of YouTube video you want to download:  ")
yt = YouTube(link)

yt_streams = yt.streams
HTTPError                                 Traceback (most recent call last)
<ipython-input-10-b722fa04aa86> in <module>()
      7 yt = YouTube(link)
      8 
----> 9 yt_streams = yt.streams

12 frames
/usr/lib/python3.7/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs)
    647 class HTTPDefaultErrorHandler(BaseHandler):
    648     def http_error_default(self, req, fp, code, msg, hdrs):
--> 649         raise HTTPError(req.full_url, code, msg, hdrs, fp)
    650 
    651 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 404: Not Found

这是我在使用 python 3.9.5 和 pytube 10.8.1 时遇到的错误

1 个答案:

答案 0 :(得分:0)

pytube 的最新版本是 10.9.3。要获得此信息,您只需运行 pip install --upgrade pytube。但是此时此升级不会解决问题,因为 HTTPError: HTTP Error 404: Not Found 是相同的。顺便说一下,这是 pytube 软件包反复出现的问题,似乎在每次更新后都会修复,但过一段时间又会再次发生。

虽然 pytube 使用起来可能很有吸引力,但我相信它是...您可能可以使用 youtube_dl 的替代方案。我发现这比 pytube 更可靠。

您可以查看他们的官方 website 以及如何install