我有点纠结于在youtube视频上迭代所有评论的语法。我使用的是python,并没有找到关于GetYouTubeVideoCommentFeed()
函数的文档。在
我真正想做的是搜索视频的所有评论,寻找一个单词的实例,并增加一个计数器(最终评论将被打印出来)。它对返回的25个结果起作用,但我需要访问其余的注释。在
import gdata.youtube
import gdata.youtube.service
video_id = 'hMnk7lh9M3o'
yt_service = gdata.youtube.service.YouTubeService()
comment_feed = yt_service.GetYouTubeVideoCommentFeed(video_id=video_id)
for comment_entry in comment_feed.entry:
comment = comment_entry.content.text
if comment.find('hi') != -1:
counter = counter + 1
print "hi: "
print counter
除了video_id
之外,我还试图设置GetYouTubeVideoCommentFeed()
的start_index
,但它不喜欢这样。在
我有什么遗漏吗?在
谢谢! 史蒂夫
下面是相同的代码片段:
知道怎么做。您可以传递一个URL,而不是向GetYouTubeVideoCommentFeed函数传递一个video_id。您可以通过更改URL参数来遍历注释。在
但一定有API限制;我只能访问视频中最后1000条评论。在
相关问题 更多 >
编程相关推荐