如何从 youtube 的 HTML5 版本获取 HTML5 视频 URL?

发布于 2024-11-19 22:42:24 字数 218 浏览 2 评论 0原文

我无法在 html5 版本的 youtube 源代码中找到标签。

问.1)。知道如何在没有视频元素的情况下播放 HTML5 视频吗?

一种选择是它从 JS 添加视频元素,但即使在 web-inspector 的 DOM 中我也无法找到视频元素。

问题 2)。如何在 web-inspector 或 firebug 中查找视频元素?

PS:我是网络开发新手。

I am not able to find tag in the source code of html5 version of youtube.

Q.1). Any idea on how it is playing HTML5 video without video element?

one option is that it is adding video element from JS, but I am not able to find out video element even in DOM of web-inspector.

Q.2). How to find video element in web-inspector or in firebug?

PS: I am novice in web-development.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

落花随流水 2024-11-26 22:42:25

当您在 Firefox 中使用查看源代码时您不会看到它,因为它是使用一些 javascript 生成的。最简单的是安装 Firebug 并选择检查元素,然后单击视频,您将看到视频标签

You won't see it when you use view source in firefox as it is generated with some javascript. Easiest is to install Firebug and select inspect element and then click on the video and you'll see the video tag

东风软 2024-11-26 22:42:24

它肯定在那里。我随机选择了一个视频,并且:

<video 
    class="video-stream" x-webkit-airplay="allow" data-youtube-id="iF83wwij828" 
    poster="http://i2.ytimg.com/vi/iF83wwij828/hqdefault.jpg" 
    src="http://v14.lscache3.c.youtube.com/videoplayback?sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Cratebypass%2Coc%3AU0hQRVVRV19FSkNOMF9NS0FD&itag=43&ip=0.0.0.0&signature=60D26B708E92E1636CA3B34A389B1A4406DF290F.BD57D8B601A61EFF68CEF6726754DAD6D9C7C2A9&sver=3&ratebypass=yes&expire=1310569200&key=yt1&ipbits=0&id=885f37c308a3f36f">
</video>

我的浏览器:Chrome 12.0。 Mac OS X 上的 742.100,带有开发人员工具 ->元素选项卡 -> 与“查看源代码”不同,搜索“

开发人员工具将向最终用户显示呈现的内容。

或者,查看名为 watch 的 JavaScript 文件。我在第 1464 行附近发现了这一点:

'PLAYER_CONFIG':
    {"url": "http:\/\/s.ytimg.com\/yt\/swfbin\/watch_as3-vfl7OZAr4.swf",
     "min_version": "8.0.0", 
    "args": {"rv.2.thumbnailUrl": "http:\/\/i4.ytimg.com\/vi\/_jjXCm3W4hA\/default.jpg",
    "rv.7.length_seconds": 374, 
    "rv.0.url": "http:\/\/www.youtube.com\/watch?v=fvVJ7U-TekE", 
    "rv.0.view_count": 14234, 
    "enablecsi": "1", 
    "rv.2.title": "Alan Grayson (HD): \"Which Foreigners Got the Fed's $500,000,000,000?\"  Bernanke: \"I Don't Know.\"", 
    "rv.4.rating": "", "rv.3.view_count": 8109, "is_doubleclick_tracked": "1",
    "rv.4.thumbnailUrl": "http:\/\/i1.ytimg.com\/vi\/PlaFDyjCeVQ\/default.jpg", 
    "fmt_url_map": "34|http:\/\/o-o.preferred.lhr14s07.v21.lscache6.c.youtube.com\/videoplayback?sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor%2Coc%3AU0hQRVVSVF9FSkNOMF9NTFhF\u0026algorithm=throttle-...

我想如果您匹配 fmt_url_map,您就会找到它。

It's definitely there. I picked a video at random, and:

<video 
    class="video-stream" x-webkit-airplay="allow" data-youtube-id="iF83wwij828" 
    poster="http://i2.ytimg.com/vi/iF83wwij828/hqdefault.jpg" 
    src="http://v14.lscache3.c.youtube.com/videoplayback?sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Cratebypass%2Coc%3AU0hQRVVRV19FSkNOMF9NS0FD&itag=43&ip=0.0.0.0&signature=60D26B708E92E1636CA3B34A389B1A4406DF290F.BD57D8B601A61EFF68CEF6726754DAD6D9C7C2A9&sver=3&ratebypass=yes&expire=1310569200&key=yt1&ipbits=0&id=885f37c308a3f36f">
</video>

My browser: Chrome 12.0.742.100 on Mac OS X, with Developer Tools -> Elements tab -> Search for "<video"

Developer Tools will show what's rendered to the end-user, unlike "view source".

Alternatively, have a look inside the JavaScript file called watch. I found this around line 1464:

'PLAYER_CONFIG':
    {"url": "http:\/\/s.ytimg.com\/yt\/swfbin\/watch_as3-vfl7OZAr4.swf",
     "min_version": "8.0.0", 
    "args": {"rv.2.thumbnailUrl": "http:\/\/i4.ytimg.com\/vi\/_jjXCm3W4hA\/default.jpg",
    "rv.7.length_seconds": 374, 
    "rv.0.url": "http:\/\/www.youtube.com\/watch?v=fvVJ7U-TekE", 
    "rv.0.view_count": 14234, 
    "enablecsi": "1", 
    "rv.2.title": "Alan Grayson (HD): \"Which Foreigners Got the Fed's $500,000,000,000?\"  Bernanke: \"I Don't Know.\"", 
    "rv.4.rating": "", "rv.3.view_count": 8109, "is_doubleclick_tracked": "1",
    "rv.4.thumbnailUrl": "http:\/\/i1.ytimg.com\/vi\/PlaFDyjCeVQ\/default.jpg", 
    "fmt_url_map": "34|http:\/\/o-o.preferred.lhr14s07.v21.lscache6.c.youtube.com\/videoplayback?sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor%2Coc%3AU0hQRVVSVF9FSkNOMF9NTFhF\u0026algorithm=throttle-...

I guess if you match for fmt_url_map, you'll find it.

冷弦 2024-11-26 22:42:24

我发现了一种更简单的方法来获取 URL。

  1. 转至 http://en.fetchfile.net/(或任何其他允许您下载视频的网站) youtube 和类似网站)
  2. 粘贴 youtube 视频链接(来自浏览器地址栏)
  3. 它会显示下载视频的链接,这实际上是视频链接。请参阅下面的屏幕截图。您可以右键单击“下载视频”按钮并“复制链接地址”。您现在已经从服务器获得了实际的视频 URL。

输入图片此处描述

这也适用于许多使用 HTML5 视频的其他网站,其中视频链接在查看源代码中不可用。

I found an even easier way to get the URL.

  1. Go to http://en.fetchfile.net/ (or any other site that lets you download videos from youtube and similar sites)
  2. Paste the youtube video link (from the browser address bar)
  3. It shows you links to download the video which is actually the video link. See screenshot below. You can right click on the 'Download video' button and 'copy link address'. You now have the actual video URL from the server.

enter image description here

This also works a lot of other sites using HTML5 video where the video link is not available in view source.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文