如何使用pytube获取youtube视频描述

How to get youtube video description with pytube

当我尝试使用此代码获取 YouTube 视频说明时:

from pytube import YouTube
video = YouTube("https://www.youtube.com/watch?v=N9bLO0XY3zs&ab_channel=CompanyEggs")
print (video.description())

我明白了

Traceback (most recent call last):
  File "C:/Users/mmthe/PycharmProjects/pythonProject1/main.py", line 24, in <module>
    print (video.description())
TypeError: 'str' object is not callable

我该如何解决这个问题?

Pytube 给你一个对象,你只需要打印/访问该对象的属性。

from pytube import YouTube

video = YouTube("https://www.youtube.com/watch?v=N9bLO0XY3zs&ab_channel=CompanyEggs")
print (video.description)

给予

Just drink another one


Song: https://www.youtube.com/watch?v=Ag1o3koTLWM