javascript - 为 youtube 搜索生成一个 url

标签 javascript youtube

我如何使用 javascript 或 php 为 youtube 生成一个 url,用于搜索特定用户帐户上的视频,并将最佳标题匹配放在顶部?

我正在使用这段代码:

<!DOCTYPE html>
<head>
    <meta charset="utf-8" />
</head>

<script type="text/javascript">
    function mysearch()
    {
        var elem=document.getElementById('inputsearchquery');
        var url="http://www.youtube.com/user/QueenVEVO/videos?query="+encodeURIComponent(elem.value);
        var win=window.open(url, '_blank');
        win.focus();
    }
</script>

<body>
    <h2>Enter search string (user: Queen)</h2>
    <input id="inputsearchquery" type="text" value="the show must go on">
    <button type="button" onclick="mysearch()">Search</button>
</body>

唯一的问题是 youtube 没有将最佳标题匹配放在顶部!视频“The show must go on”排在第 13 位,我预计它会排在首位?

谁能告诉我如何更改 url,以便 youtube 将最匹配的标题放在首位?或者我真的必须使用 youtube api 来完成这项任务吗?

最佳答案

我不确定我是否理解你的问题,但你可以使用 GET 搜索。

像这样 http://www.youtube.com/results?search_query=the+show+must+go+on&oq=the+show+must+go+on

“search_query”部分可能来自您网站的用户。您必须将其解析为 GET 语法并将其发送到 youtube。然后,您可以获得结果的来源并使用正则表达式搜索您的字符串,也许还有高浏览量或类似的东西。

但我相信学习 youtube api 会为您节省更多时间和工作!

关于javascript - 为 youtube 搜索生成一个 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15829767/

相关文章:

python - YouTube API 视频上传错误 : parseError/w python

iphone - 新的 YouTube iframe 代码无法在 iPhone 上显示视频

javascript - 正则表达式接受格式为 00.00 的数字

javascript - 如何使用 jQuery 访问元素 ID 和其他属性?

swift - 如何在无用户应用程序上使用 Google Api 上传到单个 Youtube channel

javascript - Youtube - 自定义播放图标

youtube - 将WebM视频上传到YouTube,以HTML5模式播放MP4

javascript - Angular 中的模型和集合?

javascript - 原型(prototype)继承和实例数组的问题

基于 local/prod 的 Javascript URL