songtaste網站歌曲真實URL擷取

來源:互聯網
上載者:User

標籤:des   style   blog   http   io   os   java   ar   strong   

    個人挺喜歡songtaste網站的歌曲的,下載方法也層出不窮,可是作為程式員如果不知其中原理的方法真是羞愧。首先簡單點的方法當然有google外掛程式這樣的嗅探器了,不過這種工具的原理還不是很瞭解。今天先總結一下songtaste網站部分歌曲的真實下載連結的擷取。非常感謝http://www.crifan.com/提供的songtaste歌曲下載器~學習了很多內容。

    1.開啟songtaste網站的原始碼,搜尋<div id="playicon" style="margin-left:-12px"> 。 接下來的一塊div內容及接下來擷取真實歌曲url的關鍵。

    2.接下來一塊div的格式化源碼粘貼如下: 

<div style=‘display:none;‘>    <a href="javascript:playmedia1(‘playicon‘,‘player‘, ‘b988a3d864d81432c381d8aa2f1f63b1e5f39744a99ab1911d6bfbb557876cd10a66e196e50166602f1ced3fe51ffc51‘, ‘355‘, ‘68‘, ‘b3a7a4e64bcd8aabe4cabe0e55b57af5‘, ‘http://m2.‘, ‘1357638‘,0);ListenLog(1357638, 0);">    <img src="http://image.songtaste.com/images/play_ico.gif" align="absmiddle" border="0" alt="播放當我回頭看你的一瞬(電視劇 你我一樣 片尾曲)">        <b> Listen Now</b>    </a>       (<a href="javascript:;" onClick=window.open("/playmusic.php?song_id=1357638",‘popwin_kt‘,‘menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=50,height=50‘); >彈出播放</a>)</div><script src="/stflashplayer/js/swfobject.js"></script><script>     var flashvars = { };    var params = {                      menu:"false",                scale:"noScale",                allowFullscreen:"true",                allowScriptAccess:"always",                wmode:"transparent"    };params.allowScriptAccess="always";params.hasPriority="true";params.swliveconnect="true";var attributes = {     id:"STWebPlayer" };swfobject.embedSWF("/stflashplayer/STPlayer_1.12.swf","STWebPlayer","360","70","10.0.0","/stflashplayer/expressInstall.swf", flashvars, params, attributes);function swfReady() {    var strURL = "b988a3d864d81432c381d8aa2f1f63b1e5f39744a99ab1911d6bfbb557876cd10a66e196e50166602f1ced3fe51ffc51";    var Head = "http://m2.";    var type = "b3a7a4e64bcd8aabe4cabe0e55b57af5";    var iscopy = "0";    if(strURL.indexOf(‘rayfile‘)>0 && iscopy <= 0) {        var SongUrl = Head + strURL + GetSongType(type);        var obj = {             name:"當我回頭看你的一瞬(電視劇 你我一樣 片尾曲)",            url:SongUrl,            isShowLogo:"0" ,            isAutoReplay:1,             isAutoPlay:0        };        setSongInfo(obj);    }    flashplay("b988a3d864d81432c381d8aa2f1f63b1e5f39744a99ab1911d6bfbb557876cd10a66e196e50166602f1ced3fe51ffc51", "1357638","0");    ListenLog("1357638", "0");}function setSongInfo(obj) {    try {        var stPlayerSWFobj = swfobject.getObjectById("STWebPlayer");        stPlayerSWFobj.setSongInfo(obj);    } catch(e) {         alert(e.description);     }}function playAudio() {    var stPlayerSWFobj = swfobject.getObjectById("STWebPlayer");    stPlayerSWFobj.playAudio();}function pauseAudio() {    var stPlayerSWFobj = swfobject.getObjectById("STWebPlayer");    stPlayerSWFobj.pauseAudio();}function playerPlayStart() {}function playerPaused() {}function flashplay(strURL,st_songid,t) {$.ajax( {    type:‘POST‘,    url:‘/time.php‘,    cache:false,    data:‘str=‘+strURL+‘&sid=‘+st_songid+‘&t=‘+t,    dataType:‘html‘,    success:function(data){        if(data){            var obj = {                 name:"當我回頭看你的一瞬(電視劇 你我一樣 片尾曲)",                url:data,                isShowLogo:"0" ,                isAutoReplay:1,                 isAutoPlay:0            };            setSongInfo(obj);            if(data.indexOf(‘duomi.com‘) > 0)                {                    $("#show_logo").show();                }            }     },    error:function(data) {    }    });}</script><div id="STWebPlayer"><h1>STWebPlayer</h1><p><a href="http://www.adobe.com/go/getflashplayer">Get Adobe Flash player</a></p></div>

  

    3.主要的內容就是紅色標註的地區,js的變數名也出賣了真實歌曲的url連結,這裡看到songtaste的歌曲真實連結來源之一為rayfile網盤,直接利用var SongUrl = Head + strURL + GetSongType(type)進行拼接。GetSongType(type)函數的定義在這裡:http://image.songtaste.com/inc/main.js

    

function GetSongType(md5code){switch(md5code){case "7d99bb4c7bd4602c342e2bb826ee8777":return ".wma";break;case "25e4f07f5123910814d9b8f3958385ba":return ".Wma";break;case "51bbd020689d1ce1c845a484995c0cce":return ".WMA";break;case "b3a7a4e64bcd8aabe4cabe0e55b57af5":return ".mp3";break;case "d82029f73bcaf052be8930f6f4247184":return ".MP3";break;case "5fd91d90d9618feca4740ac1f2e7948f":return ".Mp3";break;}}

  

  所以根據上面的方法可以很簡單的就拼接出存在網盤的那些真實歌曲的連結; 

    接下來就是那些ajax非同步擷取真實連結的歌曲了,其實也非常的容易;

    後來也可以發現另外一個重要的函數也在這裡,邏輯與第二部分標註紅色地區的也相當的類似,功能應該也相同,如果剛開始能夠定位到這裡也能夠輕鬆的擷取真實url連結。 

//Media Linkfunction playmedia1(playIcon, strID,strURL,intWidth,intHeight,type, Head,st_songid,t) { playIcon.replace(" ","%20");strID.replace(" ","%20");var objDiv=document.getElementById(strID);document.getElementById(playIcon).style.display=‘none‘;if (!objDiv) return false;if (objDiv.style.display!=‘none‘) {objDiv.innerHTML=‘‘;objDiv.style.display=‘none‘;} else {if(strURL.indexOf(‘rayfile‘)>0) {var SongUrl = Head + strURL + GetSongType(type);objDiv.innerHTML=makemedia_html(SongUrl,intWidth,intHeight);objDiv.style.display=‘block‘;} else {$.ajax({type:‘POST‘,url:‘/time.php‘,cache:false,data:‘str=‘+strURL+‘&sid=‘+st_songid+‘&t=‘+t,dataType:‘html‘,success:function(data){//alert(data);if(data){objDiv.innerHTML=makemedia_html(data,intWidth,intHeight);objDiv.style.display=‘block‘;if(data.indexOf(‘duomi.com‘) > 0){$("#show_logo").show();}}},error:function(data){//alert(‘error‘);}});}}}

  

    4.從上面的標註代碼可以看出,另外一個擷取真實連結的方法是針對/time.php發送請求,請求的資料格式:data:‘str=‘+strURL+‘&sid=‘+st_songid+‘&t=‘+t,  因為php檔案無法開啟,這裡利用postman類比請求擷取真實的URL連結:以下是我擷取一個具體URL執行個體的;

   

    這樣就擷取了另外一種url真實連結的方法。

songtaste網站歌曲真實URL擷取

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.