python - 如何获取TED带字幕的视频下载url
怪我咯
怪我咯 2017-04-17 11:28:02
0
1
1037

准备爬一下TED的视频,于是乎随便找到一个视频页面,点了一下download,然后跳出一个“download this talk”的浮动框,用chrome开发者工具分析了一下页面,发现点击download之后会加载一个mp4文件,截图如下:

分析这个文件即可得到视频的下载链接。但现在问题是,不知道怎么取得这个文件的url,即:http://www.ted.com/download/links/slug/MitchResnick_2012X/type/talks/ext/mp4


页面里面有

<a id="no-flash-video-download" href="http://download.ted.com/talks/AlanKay_2007.mp4?apikey=TEDDOWNLOAD">download the video</a> to play.

http://download.ted.com/talks/AlanKay_2007.mp4?apikey=TEDDOWNLOAD,重定向后确实是视频的下载地址http://video.ted.com/talk/podcast/2007/None/AlanKay_2007.mp4,但是这个视频并没有嵌入字幕。

我想要得到有字幕的视频,只能通过点击下载,得到以下的一个链接:http://www.ted.com/download/links/slug/AlanKay_2007/type/talks/ext/mp4,然后可以选择语言,这样可以得到带字幕的视频地址:http://video-subtitle.tedcdn.com/talk/podcast/2007/None/AlanKay_2007-480p-en.mp4。 问题是我不知道如何分析出点下载后加载的这个/download/links/slug/AlanKay_2007/type/talks/ext/mp4地址,因此不能进一步分析它获得视频地址。

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(1)
阿神

There is such a piece of code in the page you provided

<a id="no-flash-video-download" href="http://download.ted.com/talks/MitchResnick_2012X.mp4?apikey=TEDDOWNLOAD">download the video</a> to play.

You only need to extract the value in href. I tried it and it can be played. As for how to propose, regular or other methods can be used. It’s all very simple.


We can extract the code for him to click Download from the script

$("#downloadTalk").click(function(b) {
    b.preventDefault();
    var a = $("#videoHolder");
    showDownloadDialog(a)
});
window.showDownloadDialog = function(a) {
    var b = $("#download_dialog");
    if (a.data("downloadhtml")) {
        b.html(a.data("downloadhtml"))
    } else {
        b.load("/download/links/slug/" + talkDetails.mediaSlug + "/type/talks/ext/mp4", function(d, c, e) {
            a.data("downloadhtml", d)
        })
    }
    b.dialog("open")
};

mediaSlug is in the code below it

"duration":1008,"mediaSlug":"MitchResnick_2012X","mediaPad":15.33}</script>

Extract mediaSlug to form the address of the download page.

/download/links/slug/MitchResnick_2012X/type/talks/ext/mp4

But I don’t see a language option for my video.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template