放大镜站内搜索:


您现在的位置:首页 > 电脑 > 应用技巧 > 正文
全自动获取百度500首最热门MP3的方法
学生王国 ∥ http://www.xswg.com 更新时间:2006年10月12日 调整字体:

        currentTask=-1;
      }else{
        //获得mp3的真实地址
        analyBaiduMusic();
      }
    }
    loadBaiduMusic();
  }
}

//----分析下载内容生成歌曲地址列表----
function analyBaiduList(){
  var strHTML=b2s(xmlHttp.responseBody);
  var iStart=strHTML.search(/<body/i);
  var iEnd=strHTML.toLowerCase().indexOf("<\/script",iStart+5);
  strHTML=strHTML.substring(iStart,iEnd);
  var fff=document.createElement("Iframe");
  fff.id="tempFrame";
  fff.style.display="none";
  document.body.insertBefore(fff);
  theWin=eval("tempFrame");
  theWin.document.open();
  theWin.document.clear();
  theWin.document.write(strHTML);
  theWin.document.close();
 
  for(var i=0;i<theWin.document.links.length;i++){
    if(theWin.document.links[i].href.match(/mp3.baidu.com\/m\?tn=baidump3\&ct=/i)&&theWin.document.links[i].parentNode.firstChild==theWin.document.links[i]){
      //将url存入taskURLs,歌曲名称存入taskNames
      taskURLs[taskURLs.length]=theWin.document.links[i].href.replace(/lm=-1/,"lm=0");
      taskNames[taskNames.length]=theWin.document.links[i].innerText;
    }
  }
  fff.outerHTML="";
}

//----获得mp3的真实地址,添加到music list-----
function analyBaiduMusic(){
  var strHTML=b2s(xmlHttp.responseBody);
  var strTxt=taskNames[currentTask];
  //匹配URL的正则
  var aryURL=strHTML.match(/  http:\/\/[^ ]+  /gi);
  if(!aryURL){return(false);}
  var theC=document.createElement("DIV");
  theC.className="item";
  musicListContent.insertBefore(theC);
  //获取10个地址以免链接失效
  for(var i=0;i<10&&i<aryURL.length;i++){
    //每个item的容器
    var theD=document.createElement("DIV");
    theD.onmouseover=musicList_mouseover;
    theD.onmouseout=musicList_mouseout;
    //link元素
    var theLink=document.createElement("A");
    var strURL=aryURL[i].substring(2,aryURL[i].length-2);
    theLink.href=strURL;
    theLink.title=strURL;
    theLink.innerText=(currentTask+1)+"."+strTxt;
    if(i>0){theLink.innerText+="."+(i+1);}
    theLink.onclick=musicList_item_click;
    theD.insertBefore(theLink);
    //添加到列表按钮
    theButton=document.createElement("Span");
    theButton.className="add2ListBtn";
    theButton.innerText="1";

9共  上一页 1 2 3 4 5 6 7 8 9 下一页


相关链接
来自:幻灭的麦克风
编辑:
浏览:
评论查看全部评论
您的评论
姓名:
请您注意:
1.请遵守《中国互联网行业自律条款》及中华人民共和国其他各项有关法律法规。
2.严禁发表危害国家安全、损害国家利益、破坏民族团结、破坏国家宗教政策、破坏社会稳定、侮辱、诽谤、教唆、淫秽等内容的评论 。
3.用户需对自己在使用本站服务过程中的行为承担法律责任(直接或间接导致的)。
4.本站管理员有权保留或删除评论内容。
评论内容只代表网友个人观点,与本网站立场无关。