如何在Json中按国家/地区获取最受欢迎或查看次数最多的YouTube趋势。
以前使用youtube Feed v2。它似乎已被弃用, https://gdata.youtube.com/feeds/api/standardfeeds/IN/most_popular?v=2
我可以获取youtube api v3或趋势信息中心等任何其他结果, https://www.youtube.com/trendsdashboard
答案 0 :(得分:32)
根据YouTube指南,YouTube Feeds v2现已弃用。您应该使用YouTube Data API v3。
对于最受欢迎的视频:
<强>部分强>:
id, snippet, contentDetails, fileDetails, liveStreamingDetails, localizations, player, processingDetails, recordingDetails, statistics, status, suggestions, and topicDetails
<强>图表强>:
mostPopular
<强> regionCode 强>:
<强>键强>:
maxResults :默认值5,
答案 1 :(得分:1)
x = LeftOrRight("abc", 2)
将文件另存为Function LeftOrRight(str As Variant, len As Long) As Variant
'Uncomment this line for Left
LeftOrRight = Left(str, len)
'Uncomment this line for Right
LeftOrRight = Right(str, len)
End Function
在var maxVideos = 5;
$(document).ready(function(){
$.get(
"https://www.googleapis.com/youtube/v3/videos",{
part: 'snippet',
chart: 'mostPopular',
kind: 'youtube#videoListResponse',
maxResults: maxVideos,
regionCode: 'IN',
key: 'Your_KEY_Here'},
function(data){
var output;
$.each(data.items, function(i, item){
console.log(item);
videTitle = item.snippet.title;
description = item.snippet.description;
thumb = item.snippet.thumbnails.high.url;
channelTitle = item.snippet.channelTitle;
videoDate = item.snippet.publishedAt;
Catagoryid = item.snippet.categoryId;
cID = item.snippet.channelId;
output = '<div class="maindiv"><div>' +
'<a data-fancybox-type="iframe" class="fancyboxIframe" href="watch.php?v=' + vidId + '" target="_blank" ><img src="' + thumb + '" class="img-responsive thumbnail" ></a>' +
'</div>' +
'<div class="input-group col-md-6">' +
'<h3 class="Vtitle"><a data-fancybox-type="iframe" class="fancyboxIframe" href="watch.php?v=' + vidId + '" target="_blank">' + videTitle + '</a></h3>'+
'</div><div id="cTitle"><a href="https://www.youtube.com/channel/'+cID+'" target="_blank">'+channelTitle+'</a></div></div>' +
'<div class="clearfix"></div>';
$('#trending').append(output);
})
}
);
});
文件中.js
或HTML
div
像:
ul
检查你的出局。
id="trending"