javascript 如何获取 Vine 视频 url

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14549745/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 21:56:55  来源:igfitidea点击:

How to get Vine video url

phpjavascriptjqueryvideovine

提问by Bennett

I love vinepeekand want to make something better.

我喜欢vinepeek并希望做得更好。

I have the Vine link e.g. http://vine.co/v/bJqWrOHjMmU, however this is a link to a page, not the video URL.

我有 Vine 链接,例如http://vine.co/v/bJqWrOHjMmU,但是这是一个页面链接,而不是视频 URL。

I know it's new, but does Vine have an API, or how else would I be able to get the url of the video? I'm still puzzled as to how Vinepeek gets the video url?

我知道它是新的,但是 Vine 是否有 API,或者我还能如何获取视频的 url?我仍然对 Vinepeek 如何获取视频 url 感到困惑?

采纳答案by Steven Penny

It is in the page source; you could parse it with a JavaScript bookmarklet

它在页面源中;你可以用 JavaScript bookmarklet 解析它

function qry(sr) {
  var qa = [];
  for (var prs of sr.split('&')) {
    var pra = prs.split('=');
    qa[pra[0]] = pra[1];
  }
  return qa;
}

var alpha = document.querySelector('[name=flashvars]').getAttribute('value');
var bravo = qry(alpha);
bravo.src;

Result

结果

https://vines.s3.amazonaws.com/videos/08C49094-DFB4-46DF-8110-EEEC7D4D6115-1133-000000B8AD9BE72C_1.0.1.mp4?versionId=TQGtC5O7G7H34TleFA2LF0Er9tI8VZUe

Source

来源

回答by Antony

The JSON API has the following URL: http://vinepeek.com/video

JSON API 具有以下 URL:http: //vinepeek.com/video

You can use a web inspector / console / developer tool to check the source code.

您可以使用 Web 检查器/控制台/开发人员工具来检查源代码。

<video id="post_html5_api" class="vjs-tech" loop="" preload="auto" src="https://vines.s3.amazonaws.com/videos/08C49094-DFB4-46DF-8110-EEEC7D4D6115-1133-000000B8AD9BE72C_1.0.1.mp4?versionId=TQGtC5O7G7H34TleFA2LF0Er9tI8VZUe"></video>

The URL is:

网址是:

https://vines.s3.amazonaws.com/videos/08C49094-DFB4-46DF-8110-EEEC7D4D6115-1133-000000B8AD9BE72C_1.0.1.mp4?versionId=TQGtC5O7G7H34TleFA2LF0Er9tI8VZUe

回答by Nut KunG

This is a simple function which i use to get video src from curl result. http://vine.co/v/bJqWrOHjMmU

这是一个简单的函数,我用来从 curl 结果中获取视频 src。 http://vine.co/v/bJqWrOHjMmU

function getVineVideoFromUrl($url) {
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $res = curl_exec($ch);
    preg_match('/twitter:player:stream.*content="(.*)"/', $res, $output);
    return $output[1];
}

result

结果

https://vines.s3.amazonaws.com/v/videos/08C49094-DFB4-46DF-8110-EEEC7D4D6115-1133-000000B8AD9BE72C_1.0.1.mp4?versionId=ms6ePoPeFm6NQZkeNHegV3k_ZLV4bz9x