【问题标题】:comments extraction from youtube using gwt-youtube-api-1.0.3 in java在 java 中使用 gwt-youtube-api-1.0.3 从 youtube 中提取评论
【发布时间】:2016-08-05 22:07:18
【问题描述】:

尝试从 youtube 检索用户 cmets。代码如下

String videoId = "3u1fu6f8Hto";
    String str = "http://gdata.youtube.com/feeds/api/videos/" + videoId + "/comments";
    YouTubeQuery youtubeQuery = new YouTubeQuery(new URL(str));

    youtubeQuery.setMaxResults(50);
    youtubeQuery.setStartIndex(1);

    String videoEntryUrl = youtubeQuery.getUrl().toString();

    VideoEntry videoEntry = service.getEntry(new URL(videoEntryUrl), VideoEntry.class);

    String myUrl = youtubeQuery.getUrl().toString();  // only another name

    CommentFeed commentFeed = service.getFeed(new URL(myUrl), CommentFeed.class); // Feed response

代码显示类型不兼容:URL 无法转换为字符串

【问题讨论】:

    标签: java youtube web-scraping youtube-api youtube-data-api


    【解决方案1】:

    要从 youtube 检索 cmets,请尝试执行以下操作:

    String commentUrl = videoEntry.getComments().getFeedLink().getHref(); 
    
    CommentFeed commentFeed = service.getFeed(new URL(commentUrl), CommentFeed.class);
       for(CommentEntry comment : commentFeed.getEntries()) {
             System.out.println(comment.getPlainTextContent());
       }
    

    这是一个方便的链接:https://developers.google.com/youtube/2.0/developers_guide_java#Comments

    【讨论】:

    • 什么是videoEntry
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-05
    • 1970-01-01
    • 2021-08-25
    • 2018-01-26
    • 1970-01-01
    • 2016-09-07
    相关资源
    最近更新 更多