• <small id='RI3EQ'></small><noframes id='RI3EQ'>

        <bdo id='RI3EQ'></bdo><ul id='RI3EQ'></ul>

        <legend id='RI3EQ'><style id='RI3EQ'><dir id='RI3EQ'><q id='RI3EQ'></q></dir></style></legend>

        <i id='RI3EQ'><tr id='RI3EQ'><dt id='RI3EQ'><q id='RI3EQ'><span id='RI3EQ'><b id='RI3EQ'><form id='RI3EQ'><ins id='RI3EQ'></ins><ul id='RI3EQ'></ul><sub id='RI3EQ'></sub></form><legend id='RI3EQ'></legend><bdo id='RI3EQ'><pre id='RI3EQ'><center id='RI3EQ'></center></pre></bdo></b><th id='RI3EQ'></th></span></q></dt></tr></i><div id='RI3EQ'><tfoot id='RI3EQ'></tfoot><dl id='RI3EQ'><fieldset id='RI3EQ'></fieldset></dl></div>
        <tfoot id='RI3EQ'></tfoot>

        使用 PHP 下载 Youtube 视频

        时间:2023-10-10

      1. <legend id='AR1Xm'><style id='AR1Xm'><dir id='AR1Xm'><q id='AR1Xm'></q></dir></style></legend>
          <tbody id='AR1Xm'></tbody>
        <tfoot id='AR1Xm'></tfoot>

          <small id='AR1Xm'></small><noframes id='AR1Xm'>

        • <i id='AR1Xm'><tr id='AR1Xm'><dt id='AR1Xm'><q id='AR1Xm'><span id='AR1Xm'><b id='AR1Xm'><form id='AR1Xm'><ins id='AR1Xm'></ins><ul id='AR1Xm'></ul><sub id='AR1Xm'></sub></form><legend id='AR1Xm'></legend><bdo id='AR1Xm'><pre id='AR1Xm'><center id='AR1Xm'></center></pre></bdo></b><th id='AR1Xm'></th></span></q></dt></tr></i><div id='AR1Xm'><tfoot id='AR1Xm'></tfoot><dl id='AR1Xm'><fieldset id='AR1Xm'></fieldset></dl></div>
            • <bdo id='AR1Xm'></bdo><ul id='AR1Xm'></ul>

                  本文介绍了使用 PHP 下载 Youtube 视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在寻找一种使用 PHP 下载 Youtube 视频的方法.我已经搜索了几个小时的方法,但不幸的是,我找到的所有 Google 搜索结果都已使用多年,不再有效.

                  I am searching for a way to download Youtube videos using PHP. I have searched how to do this for hours but unfortunately all the Google results I find are years old and do not work anymore.

                  如果有人能解释如何做到这一点,或提供指向详细解释的最新文章的链接,我将不胜感激.

                  I would appreciate it if someone could explain how to do this, or give a link to an up-to-date article that explains it in detail.

                  非常感谢.

                  推荐答案

                  你应该做的第一件事是获得一个工具,比如 Fiddler 并访问 YouTube 视频页面.在 Fiddler 中,您将看到构成该页面的所有文件,包括 FLV 本身.现在,您知道视频不是 CSS 文件之一,也不是图像文件.你可以忽略这些.寻找一个大文件.如果您查看 URL,它以 /videoplayback 开头.

                  The first thing you should do is get a tool like Fiddler and visit a YouTube video page. In Fiddler, you will see all of the files that make up that page, including the FLV itself. Now, you know that the video isn't one of the CSS files, nor is it the image files. You can ignore those. Look for a big file. If you look at the URL, it begins with /videoplayback.

                  现在,一旦您找到它,请弄清楚浏览器是如何知道获取该文件的.搜索会话 (Ctrl+F) 并查找视频播放".您会在访问的第一页上看到一个点击,例如 http://www.youtube.com/watch?v=123asdf.如果你翻阅那个文件,你会看到一个带有watch-player"ID 的 DIV 标签.其中有一个脚本标签来设置 flash 播放器,里面有所有的 flash 参数.其中是视频的网址.

                  Now, once you've found it, figure out how the browser knew to get that file. Do a search through the sessions (Ctrl+F) and look for "videoplayback". You will see a hit on the first page you went to, like http://www.youtube.com/watch?v=123asdf. If you dig through that file, you'll see a DIV tag with the ID of "watch-player". Within that there is a script tag to setup the flash player, and within that are all of the flash parameters. Within those is the URL to the video.

                  所以现在您知道如何使用您的工具来确定浏览器是如何做到的.你如何在 PHP 中复制这种行为?

                  So now you know how to use your tools to figure out how the browser got to it. How do you duplicate this behavior in PHP?

                  在引用视频的页面上执行 file_get_contents().忽略不在那个 watch-player div 中的所有内容.解析代码,直到找到包含 URL 的变量.从那里您可能必须取消该 URL 的转义.获得后,您可以执行 file_get_contents()(或其他一些下载方法,具体取决于您要执行的操作)来获取 URL.就是这么简单.您的 HTML 解析代码将是最复杂的.

                  Do a file_get_contents() on the page that references the video. Ignore everything not in that watch-player div. Parse through the code until you find that variable that contains the URL. From there you will probably have to unescape that URL. Once you have it, you can do a file_get_contents() (or some other download method, depending on what you are trying to do) to get the URL. it is that simple. Your HTML parsing code will be the most complex.

                  最后,请记住您将要执行的操作可能是非法的.检查 EULA.

                  Finally, keep in mind what you are about to do may be illegal. Check the EULA.

                  这篇关于使用 PHP 下载 Youtube 视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在多个客户端上同步播放 YouTube 视频? 下一篇:从 curl 或 get_video_info 获取 youtube 视频 URL

                  相关文章

                1. <i id='YwI9z'><tr id='YwI9z'><dt id='YwI9z'><q id='YwI9z'><span id='YwI9z'><b id='YwI9z'><form id='YwI9z'><ins id='YwI9z'></ins><ul id='YwI9z'></ul><sub id='YwI9z'></sub></form><legend id='YwI9z'></legend><bdo id='YwI9z'><pre id='YwI9z'><center id='YwI9z'></center></pre></bdo></b><th id='YwI9z'></th></span></q></dt></tr></i><div id='YwI9z'><tfoot id='YwI9z'></tfoot><dl id='YwI9z'><fieldset id='YwI9z'></fieldset></dl></div>

                      <small id='YwI9z'></small><noframes id='YwI9z'>

                    1. <legend id='YwI9z'><style id='YwI9z'><dir id='YwI9z'><q id='YwI9z'></q></dir></style></legend>
                      • <bdo id='YwI9z'></bdo><ul id='YwI9z'></ul>
                    2. <tfoot id='YwI9z'></tfoot>