gpt4 book ai didi

java - 检索 YouTube 的通讯网络时发生错误

转载 作者:行者123 更新时间:2023-12-01 14:03:42 26 4
gpt4 key购买 nike

我正在尝试检索前 50 条评论,这是代码:

package com.youtube;

import java.net.URL;
import com.google.gdata.client.youtube.YouTubeQuery;
import com.google.gdata.client.youtube.YouTubeService;
import com.google.gdata.data.youtube.CommentFeed;
import com.google.gdata.data.youtube.VideoEntry;

public class Ex_Y1

{

public static void main(String args[]) throws Exception
{
YouTubeService service = new YouTubeService("MyApp");

String str = "http://gdata.youtube.com/feeds/api/videos/" + 1000;

YouTubeQuery youtubeQuery = new YouTubeQuery(new URL(str));

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

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

if (videoEntry.getComments() != null) {
String commentUrl = videoEntry.getComments().getFeedLink().getHref();
System.out.println(commentUrl);

YouTubeQuery youtubeQuery1 = new YouTubeQuery(new URL(commentUrl));
youtubeQuery1.setMaxResults(50);


youtubeQuery.setStartIndex(1);
String commentUrlFeed = youtubeQuery.getUrl().toString();
CommentFeed commentFeed = service.getFeed(new URL(commentUrlFeed),CommentFeed.class);

for (int i = 0; i < commentFeed.getEntries().size()
&& commentFeed.getEntries().get(i) != null; i++) {

String author=commentFeed.getEntries().get(i).getAuthors().get(0).getUri().substring(41);
String commentId=commentFeed.getEntries().get(i).getId().substring(47);
String comment=commentFeed.getEntries().get(i).getPlainTextContent();

System.out.print(author);
System.out.print(commentId);
System.out.print(comment);
}
}

}

}

但是发生了这个错误:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingException
at com.youtube.Ex_Y1.main(Ex_Y1.java:16)

Caused by: java.lang.ClassNotFoundException: javax.mail.MessagingException

at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more

最佳答案

不要使用 google-collect-1.0 jar 文件。请使用guava-10.0.1.jar代替它。

关于java - 检索 YouTube 的通讯网络时发生错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19113644/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com