2
IveはYoutubeからデータを取得する方法に関する情報を研究しています。基本的には、再生リスト(例:http://gdata.youtube.com/feeds/api/playlists/6A40AB04892E2A1F)から動画(タイトル、説明、サムネイルURL)に関する情報を得ることです。しかし、私は非常にあなたがサムネイルURLを取得する方法を見つけ出すことはできませんgdataを使用してYouTubeのサムネイルURLを取得していますか?
String featuredFeed = "http://gdata.youtube.com/feeds/api/playlists/6A40AB04892E2A1F";
url = new URL(featuredFeed);
URLConnection connection;
connection = url.openConnection();
HttpURLConnection httpConnection = (HttpURLConnection) connection;
int responseCode = httpConnection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
InputStream in = httpConnection.getInputStream();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
Document dom = db.parse(in);
Element docEle = dom.getDocumentElement();
NodeList nl = docEle.getElementsByTagName("entry");
// NodeList nl2 = ;
if (nl != null && nl.getLength() > 0) {
for (int i = 0; i < nl.getLength(); i++) {
Element entry = (Element) nl.item(i);
Element title = (Element) entry.getElementsByTagName(
"title").item(0);
String titleStr = title.getFirstChild().getNodeValue();
Log.i("TEST LOG", "TITLES: " + titleStr);
}
}
}
:私は(私は別の質問から借りた)このコードスニペットを使用してタイトルを検索することができました。タグを見たことがありますが、ノードリストから呼び出す方法はわかりません。 この方法で、動画のサムネイルURLと動画の説明をどのように取得することができますか?
ありがとうございます。
このように考える必要はありません。 HtmlUnitのようなライブラリやXPathクエリの使い方を見て、ここでやっているような苦しい繰り返しを避けてください。 – Zecas