【发布时间】:2020-12-03 17:20:36
【问题描述】:
我是 python 脚本的新手,我正在尝试使用 beautifulsoup 来获取 youtube 视频的信息,例如标题、描述、观看次数和喜欢的次数。我应该如何在不使用 Youtube API 而是使用 beautifulsoup 的情况下做到这一点。 现在我点击检查并点击 youtube 视频的标题,
<h1 class="title style-scope ytd-video-primary-info-renderer">
<yt-formatted-string force-default-style="" class="style-scope ytd-video-primary-info-renderer">
Tucker: Kamala Harris may end up running the country</yt-formatted-string></h1>
我的代码是
# I also try use class as title style-scope ytd-video-primary-info-renderer
for i in soup.findAll('h1',{'class':'style-scope ytd-video-primary-info-renderer'}):
videoName.append(i)
但它没有得到视频的标题。这也不适用于获取视频描述和 veido 喜欢和观看。有人可以帮我找到我应该如何搜索那些使用beautifulsoup的人吗?非常感谢!!!
【问题讨论】:
标签: python html beautifulsoup scripting youtube