Pytube:urllib.error.HTTPError:HTTP 错误 410:消失了

Posted

技术标签:

【中文标题】Pytube:urllib.error.HTTPError:HTTP 错误 410:消失了【英文标题】:Pytube: urllib.error.HTTPError: HTTP Error 410: Gone 【发布时间】:2021-10-11 06:34:10 【问题描述】:

我现在在几个程序上都遇到了这个错误 我已经尝试升级 pytube,重新安装,尝试了一些修复,更改了 url 和代码 但似乎没有任何效果

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)

#Showing details
print("Title: ",yt.title)
print("Number of views: ",yt.views)
print("Length of video: ",yt.length)
print("Rating of video: ",yt.rating)
#Getting the highest resolution possible
ys = yt.streams.get_highest_resolution()

#Starting download
print("Downloading...")
ys.download()
print("Download completed!!")

这是错误代码,请帮忙!!

  File "C:\Users\Madjid\PycharmProjects\pythonProject\app2.py", line 6, in <module>
    yt = YouTube(link)
  File "C:\Users\Madjid\PycharmProjects\pythonProject\venv\lib\site-packages\pytube\__main__.py", line 91, in __init__
    self.prefetch()
  File "C:\Users\Madjid\PycharmProjects\pythonProject\venv\lib\site-packages\pytube\__main__.py", line 181, in prefetch
    self.vid_info_raw = request.get(self.vid_info_url)
  File "C:\Users\Madjid\PycharmProjects\pythonProject\venv\lib\site-packages\pytube\request.py", line 36, in get
    return _execute_request(url).read().decode("utf-8")
  File "C:\Users\Madjid\PycharmProjects\pythonProject\venv\lib\site-packages\pytube\request.py", line 24, in _execute_request
    return urlopen(request)  # nosec
  File "E:\Python\lib\urllib\request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "E:\Python\lib\urllib\request.py", line 523, in open
    response = meth(req, response)
  File "E:\Python\lib\urllib\request.py", line 632, in http_response
    response = self.parent.error(
  File "E:\Python\lib\urllib\request.py", line 555, in error
    result = self._call_chain(*args)
  File "E:\Python\lib\urllib\request.py", line 494, in _call_chain
    result = func(*args)
  File "E:\Python\lib\urllib\request.py", line 747, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "E:\Python\lib\urllib\request.py", line 523, in open
    response = meth(req, response)
  File "E:\Python\lib\urllib\request.py", line 632, in http_response
    response = self.parent.error(
  File "E:\Python\lib\urllib\request.py", line 561, in error
    return self._call_chain(*args)
  File "E:\Python\lib\urllib\request.py", line 494, in _call_chain
    result = func(*args)
  File "E:\Python\lib\urllib\request.py", line 641, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 410: Gone

【问题讨论】:

这个问题最近在这里被问及回答:How do I download YouTube videos with Python? 【参考方案1】:

如果您还没有,请在您的 PC 上安装 Git: https://git-scm.com/download/win

然后以管理员身份打开命令窗口并安装此补丁:

python -m pip install git+https://github.com/Zeecka/pytube@fix_1060

就是这样。它对我有用。

【讨论】:

【参考方案2】:

尝试升级,11.0.0版本有修复:

python -m pip install --upgrade pytube

【讨论】:

【参考方案3】:

您可以从官方 GitHub 存储库获取最新版本 https://github.com/pytube/pytube

python3 -m pip install git+https://github.com/pytube/pytube

Updated to pytube 11.0.2

【讨论】:

以上是关于Pytube:urllib.error.HTTPError:HTTP 错误 410:消失了的主要内容,如果未能解决你的问题,请参考以下文章

Python下载具有特定文件名的youtube

如何读取 save.txt 文件并将其设置为标签