【问题标题】:Download video from YouTube: HTTPError: HTTP Error 404: Not Found从 YouTube 下载视频:HTTPError:HTTP 错误 404:未找到
【发布时间】:2021-07-24 18:30:47
【问题描述】:

我使用pytube 从 YouTube 下载视频文件。代码运行良好,但最近开始抛出HTTPError: HTTP Error 404: Not Found。我该如何解决?或者有没有其他类似的 Python 库可以用来从 YouTube 下载视频?

from pytube import YouTube

def downloadVideoFromYoutube(videourl, path):
    yt = YouTube(videourl)
    yt = yt.streams.filter(progressive=True, file_extension="mp4").order_by("resolution").desc().first()
    if not os.path.exists(path):
        os.makedirs(path)
    yt.download(path)

错误:

/anaconda/envs/azureml_py36/lib/python3.6/urllib/request.py 在 http_error_default(self, req, fp, code, msg, hdrs) 648 类 HTTPDefaultErrorHandler(BaseHandler): 第649章 --> 650 引发 HTTPError(req.full_url, code, msg, hdrs, fp) 651 652类HTTPRedirectHandler(BaseHandler):

HTTPError:HTTP 错误 404:未找到

我遵循了thread 的建议,但它对我不起作用:

两者都没有:

pip install pytube==10.8.5

也不:

pip install git+https://github.com/ssuwani/pytube

也不:

python -m pip install --upgrade pytube

【问题讨论】:

  • @MDR:是的,据我所知。我正在运行10.9.3
  • 对不起,当我看到你更新问题时删除了我的评论。也许这是new bug。打倒 YT 视频总是猫捉老鼠。
  • @MDR:我切换到“youtube_dl”,它解决了这个问题。

标签: python http pytube


【解决方案1】:

Anaconda 环境可能会抛出“HTTP 错误”。直接在 cmd 中运行 py 代码,例如在 windows 中:> python yourfilname.py

【讨论】:

  • 谢谢。我切换到“youtube_dl”并解决了这个问题。
【解决方案2】:

这是 pytube 的一个错误,它以前发生过并已修复,但看起来它可能已被重新引入。您总是可以查看另一个库,例如youtube_dl 或 ytpy 或者只是尝试卸载 pytube 并安装 pytube3。 (pip 卸载 pytube) (点安装 pytube3)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-21
    • 1970-01-01
    • 2021-10-03
    • 1970-01-01
    • 2017-09-13
    • 2010-11-08
    • 2014-05-25
    • 2020-07-24
    相关资源
    最近更新 更多