有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

javascript下载iFramePlayer视频

我想下载一个可用的视频here。如右上角所示,它可能位于^{}上,因此让我们检查页面源代码

这是您感兴趣的html代码片段:

<div id="zype_5387dd4269702d063f000000" style="position: relative; padding-bottom: 56.25%; padding-top: 0; height: 0; overflow: hidden;">
    <div style="position: relative; padding-bottom: 56.25%; padding-top: 0; height: 0; overflow: hidden;">
        <iframe frameborder="0" width="100%" height="100%" id="_video_5387dd4269702d063f000000" src="https://www.crunchyroll.com/affiliate_iframeplayer?aff=af-88206-hkyj&amp;media_id=663121&amp;video_format=0&amp;video_quality=0&amp;auto_play=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" nuan_newframe="true"></iframe>
    </div>
</div>

检查显示,视频嵌入在iframe中,并且确实托管在Crunchyroll上。还需要注意的是src attribute是直接指向视频播放器页面的链接

在播放器页面上,HTML如下所示:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"lang="de" xml:lang="de">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    <link rel="icon" href="/favicon.png" />
    <title></title>
    <script type="text/javascript" src="https://www.crunchyroll.com/common/static/js/swfobject.js"></script>

    <link rel="stylesheet" type="text/css" href="https://www.crunchyroll.com/css//20150727144515.1ae5987b9d8aa2552cc16fb8eadc8e78/crcommon/reset.css"/>
    <style>
      body {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        background-color: #000;
        color: #FFF;
      }

      #content {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
      }
   </style>
    <!--[if IE]>
        <style type="text/css">
          .clearfix { zoom: 1; /* triggers hasLayout */ display: block; /* resets display for IE/Win */}
          .clearfix {display: inline-block;}  /* for IE/Mac */
        </style>
    <![endif]-->
  </head>
  <body>
    <div id="content"><div id="the_embedded_player" style="display:block;" ><div style="color:red; text-align:center; margin:16px 0px;">You either have Javascript turned off or an old version of Flash Player.<br/><br/>  <a href="http://www.adobe.com/go/getflashplayer" rel="nofollow">Get the latest Flash Player</a></div></div><script type="text/javascript"><!--
swfobject.embedSWF("https:\/\/www.crunchyroll.com\/flash\/20150615120132.eb0aab8f716ea6981edb6397bd93ffc3\/StandardVideoPlayer.swf",'the_embedded_player','100%', '100%', '9.0.115','https://www.crunchyroll.com/common/static/flash/express_install.swf',{"config_url":"http%3A%2F%2Fwww.crunchyroll.com%2Fxml%2F%3Freq%3DRpcApiVideoPlayer_GetStandardConfig%26media_id%3D663121%26video_format%3D0%26video_quality%3D0%26auto_play%3D0%26aff%3Daf-88206-hkyj%26show_pop_out_controls%3D0%26enable_next%3D0%26lang%3DdeDE"},{"wmode":"transparent","allowFullScreen":"true","allowscriptaccess":"always","allownetworking":"all"},{"id":"the_embedded_player","style":"display:block;"},null);
//--></script></div>
    <!--  pylon16 : c64387480c -->
  </body>
</html>

很明显,视频必须是^{}闪存视频文件embedSWF被调用,它被定义为here,看起来像这样(after beautifying):

embedSWF: function(ab, ah, ae, ag, Y, aa, Z, ad, af, ac) {
    var X = {
        success: false,
        id: ah
    };
    if (M.w3 && !(M.wk && M.wk < 312) && ab && ah && ae && ag && Y) {
        w(ah, false);
        K(function() {
            ae += "";
            ag += "";
            var aj = {};
            if (af && typeof af === r) {
                for (var al in af) {
                    aj[al] = af[al]
                }
            }
            aj.data = ab;
            aj.width = ae;
            aj.height = ag;
            var am = {};
            if (ad && typeof ad === r) {
                for (var ak in ad) {
                    am[ak] = ad[ak]
                }
            }
            if (Z && typeof Z === r) {
                for (var ai in Z) {
                    if (typeof am.flashvars != D) {
                        am.flashvars += "&" + ai + "=" + Z[ai]
                    } else {
                        am.flashvars = ai + "=" + Z[ai]
                    }
                }
            }
            if (F(Y)) {
                var an = u(aj, am, ah);
                if (aj.id == ah) {
                    w(ah, true)
                }
                X.success = true;
                X.ref = an
            } else {
                if (aa && A()) {
                    aj.data = aa;
                    P(aj, am, ah, ac);
                    return
                } else {
                    w(ah, true)
                }
            }
            if (ac) {
                ac(X)
            }
        })
    } else {
        if (ac) {
            ac(X)
        }
    }
}

这段模糊的代码看起来不会在任何地方出现

将html中的每个链接复制并粘贴到浏览器中似乎不允许下载视频(这一想法取自here)。如何获取正确的url

注:
下载视频文件的编程代码不是这里的重点,但我将使用this进行html解析,使用this下载文件


共 (0) 个答案