Created
August 31, 2010 22:47
-
-
Save jrabbit/559913 to your computer and use it in GitHub Desktop.
download youtube comments
This file contains 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 | |
import gdata.youtube.service | |
from BeautifulSoup import BeautifulSoup | |
yt_service = gdata.youtube.service.YouTubeService() | |
# The YouTube API does not currently support HTTPS/SSL access. | |
yt_service.ssl = False | |
yt_service.developer_key = "AI39si6sDAt4km6PVp3cw5U4MIoUAVKi-R0hVSALYdjz7EIH_Leik-7s_fxeHQZKpx6fXilSx5PvYqhk16Gg1APQFJDRncXh6g" | |
yt_service.client_id = "yt comments" | |
def get_comments(): | |
feed = yt_service.GetRecentlyFeaturedVideoFeed() | |
#comment_feed = yt_service.GetYouTubeVideoCommentFeed(video_id=youtube_id) | |
for entry in feed.entry: | |
url = BeautifulSoup(str(entry.comments)).find('ns0:feedlink')['href'] | |
comment_feed = yt_service.GetYouTubeVideoCommentFeed(url) | |
for comment_entry in comment_feed.entry: | |
return str(BeautifulSoup(comment_entry.ToString()).find('ns0:content').contents) | |
#find ns0:content and get content, make it nonutf. | |
if __name__ == '__main__': | |
print get_comments() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment