gpt4 book ai didi

api - 在Youtube API中进行词组搜索

转载 作者:行者123 更新时间:2023-12-03 05:35:38 28 4
gpt4 key购买 nike

在Youtube API的2.0版中(已停产),API文档规定了如何制定复合/词组搜索的逻辑,API v3.0的等效信息是什么?
我需要怎么做才能将关键字转换为可以在API v3.0上使用?
以下是v2.0的文字:

The q parameter specifies a search query term. YouTube will search allvideo metadata for videos matching the term. Video metadata includestitles, keywords, descriptions, authors' usernames, and categories.Note that any spaces, quotes or other punctuation in the parametervalue must be URL-escaped.

To search for an exact phrase, enclose thephrase in quotation marks. For example, to search for videos matchingthe phrase "spy plane", set the q parameter to %22spy+plane%22. Yourrequest can also use the Boolean NOT (-) and OR (|) operators toexclude videos or to find videos that are associated with one ofseveral search terms. For example, to search for videos matchingeither "boating" or "sailing", set the q parameter toboating|sailing. (Note that the pipe character must be URL-escaped.)Similarly, to search for videos matching either "boating" or "sailing"but not "fishing", set the q parameter to boating|sailing+-fishing.

最佳答案

您可以测试此api过滤器是否相同:此处是youtube和Wikipedia的示例。如您在浏览器调试器上可以显示的,所有参数都通过管道“|”发送到参数“q” ...

window.searchModule = {

cors: "http://crossorigin.me/",
wikiEndpoint: "https://en.wikipedia.org/w/api.php",
ytEndpoint: "https://www.googleapis.com/youtube/v3/search",
ytKey: "AIzaSyDsPK3Cs1A4ipMjNr147ubG5HpoDyW6zzk",

init: function(sentSearch) {
var self = this,
bandCheck = $("#bandCheckbox").is(":checked");

if(bandCheck == true) {
sentSearch = sentSearch + "+(band)";
}

self.wikiSearch(sentSearch);
self.ytSearch(sentSearch);
self.watchers();
},

wikiSearch: function(sentSearch) {
var self = this;

$.ajax({
url: self.cors + self.wikiEndpoint + "?action=query&list=search&srsearch=" + sentSearch + "&srlimit=1&format=json",
success: function(response) {
//console.log(response.query);
self.formatWiki(response.query);
},

error: function(response) {
console.log(response);
}
})
} .....

https://codepen.io/anon/pen/QqmgGB

关于api - 在Youtube API中进行词组搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46636066/

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