Mad*_*jid 21 python http http-error pytube
我现在在几个程序上都遇到了这个错误。我尝试升级 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!!")
Run Code Online (Sandbox Code Playgroud)
这是错误代码:
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!!")
Run Code Online (Sandbox Code Playgroud)
mit*_*hus 31
尝试升级一下,11.0.0版本有修复:
python -m pip install --upgrade pytube
Run Code Online (Sandbox Code Playgroud)
如果您还没有安装 Git,请在您的 PC 上安装: https ://git-scm.com/download/win
然后以管理员身份打开命令窗口并安装此补丁:
python -m pip install git+https://github.com/Zeecka/pytube@fix_1060
Run Code Online (Sandbox Code Playgroud)
小智 6
我从头到尾构建了我的,并遇到了同样的问题,这里是代码和步骤。
代码:
from pytube import YouTube
from sys import argv
link = argv[1]
yt = YouTube(link)
yd = yt.streams.get_highest_resolution()
yd.download(r'C:/Users/adam/OneDrive/Desktop/video')
Run Code Online (Sandbox Code Playgroud)
出现错误:
urllib.error.HTTPError: HTTP Error 410: Gone
Run Code Online (Sandbox Code Playgroud)
脚步:
python -m pip install --upgrade pytube
python3 -m pip install git+https://github.com/pytube/pytube
担任管理员。
工作得很好!
不久前,我启动了一个下载 YT 视频(MP4)的个人项目,我遇到了同样的问题以及其他问题。所有答案都有帮助,但需要结合其中 2-3 个答案才能解决我的问题:
首先,我必须下载 Git For Windows:( https://git-scm.com/download/win ) 然后,我使用以下命令降级已经安装的 PyTube 包。这将安装 PyTube 10.9.3:
`python -m pip install git+https://github.com/Zeecka/pytube@fix_1060`
Run Code Online (Sandbox Code Playgroud)
最后,我重新安装了最新版本的PyTube(此命令安装最新版本):
`pip install --upgrade pytube`
Run Code Online (Sandbox Code Playgroud)
不确定到底是什么导致 PyTube 在第一次安装时崩溃,但降级然后升级对我有用。
对于任何疑问,最终产品代码如下所示。以 720p 分辨率下载的视频,其标题为保存文件的名称。
from pytube import YouTube
#where to save
SAVE_PATH = "C:/YOUR/DESIRED/FILE/PATH/"
#link of the video to be downloaded
link = input("Enter URL >> ")
try:
yt = YouTube(link)
mp4_files = yt.streams.filter(file_extension="mp4")
mp4_720p_files = mp4_files.get_by_resolution("720p")
mp4_720p_files.download(SAVE_PATH)
except Exception as e:
print("ERROR: ", e)
Run Code Online (Sandbox Code Playgroud)
资料来源:
HTTP 错误 410“消失”- https://www.youtube.com/watch?v=rrRuBrUrnCw
适用于 Windows 的 Git - https://git-scm.com/download/win
| 归档时间: |
|
| 查看次数: |
28042 次 |
| 最近记录: |