Created
September 17, 2013 20:01
-
-
Save fnielsen/6599783 to your computer and use it in GitHub Desktop.
Example of iteration over YouTube comments with Python.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gdata.youtube.service | |
yts = gdata.youtube.service.YouTubeService() | |
urlpattern = "http://gdata.youtube.com/feeds/api/videos/" + \ | |
"9ar0TF7J5f0/comments?start-index=%d&max-results=25" | |
index = 1 | |
url = urlpattern % index | |
comments = [] | |
while True: | |
ytfeed = yts.GetYouTubeVideoCommentFeed(uri=url) | |
comments.extend([comment.content.text for comment in ytfeed.entry]) | |
if not ytfeed.GetNextLink(): break | |
url = ytfeed.GetNextLink().href |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment