当我在YouTube上进行基本的标签搜索时,我试图获得相同的结果,如下所示:
https://www.youtube.com/results?search_query=%23beautyblogger
通过API,但我的结果很有用,通常会返回不包含搜索字词的视频。
这是我正在提出的要求:
https://www.googleapis.com/youtube/v3/search?key=MY-API-KEY&part=snippet&q=%23beautyblogger
结果:
{
kind:"youtube#searchListResponse",
etag:"" kiOs9cZLH2FUp6r6KJ8eyq_LIOk/i5Di8j0849qCyu2Tmld5tGkydbI"",
nextPageToken:"CAMQAA",
regionCode:"US",
pageInfo:{
totalResults:562,
resultsPerPage:3
},
items:[
{
kind:"youtube#searchResult",
etag:"" kiOs9cZLH2FUp6r6KJ8eyq_LIOk/vn2S6wZ0OslYJuMhhbhtIlqU1IU"",
id:{
kind:"youtube#video",
videoId:"9-JNIsGngVQ"
},
snippet:{
publishedAt:"2014-08-21T11:32:49.000Z",
channelId:"UCXeW7-Cm1Sj4yiH5GTNOonQ",
title:"Ice Bucket Challange TH #BeautyBlogger #Als",
description:"Video created with the Socialcam app: https://socialcam.com.",
thumbnails:{
default:{
url:"https://i.ytimg.com/vi/9-JNIsGngVQ/default.jpg",
width:120,
height:90
},
medium:{
url:"https://i.ytimg.com/vi/9-JNIsGngVQ/mqdefault.jpg",
width:320,
height:180
},
high:{
url:"https://i.ytimg.com/vi/9-JNIsGngVQ/hqdefault.jpg",
width:480,
height:360
}
},
channelTitle:"beauty4ties",
liveBroadcastContent:"none"
}
},
{
kind:"youtube#searchResult",
etag:"" kiOs9cZLH2FUp6r6KJ8eyq_LIOk/pIFcPza36XlfcFxov8SKHlr8b84"",
id:{
kind:"youtube#video",
videoId:"eJEZx3N_cM0"
},
snippet:{
publishedAt:"2015-04-14T21:39:47.000Z",
channelId:"UCwM3ZfCiQuq-65OGMKYuZ6Q",
title:"Confessions of a Beauty Blogger",
description:"A fun Q&A tag on Confessions of a Beauty Blogger...",
thumbnails:{
default:{
url:"https://i.ytimg.com/vi/eJEZx3N_cM0/default.jpg",
width:120,
height:90
},
medium:{
url:"https://i.ytimg.com/vi/eJEZx3N_cM0/mqdefault.jpg",
width:320,
height:180
},
high:{
url:"https://i.ytimg.com/vi/eJEZx3N_cM0/hqdefault.jpg",
width:480,
height:360
}
},
channelTitle:"Karen Heidi Rees",
liveBroadcastContent:"none"
}
},
{
kind:"youtube#searchResult",
etag:"" kiOs9cZLH2FUp6r6KJ8eyq_LIOk/oz9Nm1GJb6xtqYeWq_3znkaYCWE"",
id:{
kind:"youtube#channel",
channelId:"UC4PsH3qz3AYe6QJubmD45wQ"
},
snippet:{
publishedAt:"2014-03-25T01:03:10.000Z",
channelId:"UC4PsH3qz3AYe6QJubmD45wQ",
title:"Synergy By Design #BeautyBlogger",
description:"BeautyBlogger 》#Beauty ¤ #Makeup ¤ #Style 》BBA:MKT/PR ¤ #SocialMedia Expert 》Ranked Top#1% #SocialMediaInfluencer (Self-Taught)》100% Sicilian ...",
thumbnails:{
default:{
url:"https://yt3.ggpht.com/-gUShxLkVxac/AAAAAAAAAAI/AAAAAAAAAAA/YzSK2QBuysw/s88-c-k-no-rj-c0xffffff/photo.jpg"
},
medium:{
url:"https://yt3.ggpht.com/-gUShxLkVxac/AAAAAAAAAAI/AAAAAAAAAAA/YzSK2QBuysw/s240-c-k-no-rj-c0xffffff/photo.jpg"
},
high:{
url:"https://yt3.ggpht.com/-gUShxLkVxac/AAAAAAAAAAI/AAAAAAAAAAA/YzSK2QBuysw/s240-c-k-no-rj-c0xffffff/photo.jpg"
}
},
channelTitle:"Synergy By Design #BeautyBlogger",
liveBroadcastContent:"none"
}
}
]
}
web search结果中没有一个,第二个甚至不包含确切的搜索字词。
我可以通过任何方式修改我的请求以获得与网络搜索相同的结果吗?
答案 0 :(得分:1)
您可以使用Search:list
获取API请求中指定的匹配结果列表。搜索结果集标识匹配的视频,频道和播放列表资源。
以下是Advanced search
的文档,您可以使用高级搜索运算符查看您要搜索的视频的列表。例如,hashtag,使用##"[tag name]"
。使用标记搜索带有您请求的标记的视频。
示例:
##"Game Reviews" shows a list of all the videos with the tag "Game Reviews."
以下是包含标记的示例请求:
GET https://www.googleapis.com/youtube/v3/search?part=snippet&q=%23%23{YOUR_TAG}&key={YOUR_API_KEY}
我发现这个与您的查询相关的堆栈溢出票,您可以尝试社区提供的工作: How to retrieve a YouTube video's tags with YouTube v3 API?