【发布时间】: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”,它解决了这个问题。