前提
youtubeのチャンネルのRSSから、新着動画の情報を取得したい
GASで実装中
サムネイルのURLの取得がうまくいかない(let thumbnail ~~の行)が、どうしたら取得できるでしょうか
youtubeAPIはやりたいことを実装するとquotaがかなりオーバーしてしまうので使用しない予定です
発生している問題・エラーメッセージ
TypeError: Cannot read property 'getChild' of null
entry.getChild('group',media)
が空になってしまうみたいなので、名前空間等の問題かなと思っています
該当のソースコード
// RSSの読み込み let xml = UrlFetchApp.fetch('https://www.youtube.com/feeds/videos.xml?user=youtubejapan').getContentText() let document = XmlService.parse(xml) let root = document.getRootElement() let atom = XmlService.getNamespace('http://www.w3.org/2005/Atom') let media = XmlService.getNamespace('media','http://search.yahoo.com/mrss'); let entries = root.getChildren('entry', atom) // RSSから取得 for (var entry of entries) { let title = entry.getChild('title', atom).getText() let thumbnail = entry.getChild('group',media).getChild('thumbnail',media).getAttribute('url').getValue() console.log(title ); console.log(thumbnail); }

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/08/07 12:22