1

我正在尝试使用 pytube 模块下载 youtube 视频,但每次运行它时都会出现此错误:

raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

这是我正在尝试制作的网络应用程序

代码:

from pytube import Youtube

print("What would you like to download ?")
print(f"1/Youtube Video, 2/Image, 3/Song")
userinput = int(input())

if userinput == 1:
    n()


def n():
    print("insert url:")
    u = input()
    download_videos(u)


def download_videos(link):
    yt = YouTube(link)
    yt.streams.filter(progressive=True, file_extension='mp4').order_by(
        'resolution').desc().first().download()
4

0 回答 0