a little bit of tech, a little bit of green, to help tame the savage techmachine.

首先分析http://music.xidu.net/album/album3314.html的源代码片断如下:

<TD width=25><FONT color=#6633cc>:::</FONT></TD></TR><!-- *************************************Main Part************************************************ -->
                    <TR>
                      <TD class=bigger><A title=发表评论,目前共有条评论
                        href="javascript:ShowVote(39653,'无印良品','01-掌心')">01</A><A
                        title=查看歌词 href="javascript:popwin(39653)"><IMG
                        src="ahnan 滚石香港黄金十年-光良品冠精选-无印良品++音乐无限+阿南在线.files/lyric_yes.gif"
                        border=0></A></TD>
                      <TD class=bigger><A
                        href="http://music.xidu.net/down.asp?songid=39653"><IMG
                        onmouseover="this.src='../images/down_arrow_yellow.gif'"
                        onclick="this.src='../images/down_arrow_yellow.gif'"
                        onmouseout="this.src='../images/down_arrow_green.gif'"
                        src="ahnan 滚石香港黄金十年-光良品冠精选-无印良品++音乐无限+阿南在线.files/down_arrow_green.gif"
                        border=0></A></TD>
                      <TD class=bigger>(4.05M)</TD>
                      <TD class=bigger><INPUT id=ids1 type=checkbox
                        value=39653 name=ids></TD>
                      <TD class=bigger><A
                        href="http://music.xidu.net/play.asp?id=39653">掌心</A></TD>
                      <TD></TD>


然后写了一个vc的小程序将mp3文件链接提取出来,放到bglist.js文件里,供首页的播放器读取该列表文件。

void CTestDlg::OnOK()
{
 // TODO: Add extra validation here
 CStdioFile file;

 file.Open("1.htm",CFile::modeRead);

 file.SeekToBegin();
 CString str;
 BOOL bFind=FALSE;
 BOOL bEnd=file.ReadString(str);
 while(!bFind && bEnd)
 {
  if(str.Find("*****Main Part******")>=0)
  {
   bFind=TRUE;
   break;
  }
  bEnd=file.ReadString(str);
 }
 
 CStdioFile desfile;
 desfile.Open("bglist.js",CFile::modeCreate|CFile::modeWrite);
 desfile.SeekToBegin();

 bFind=FALSE;
 bEnd=file.ReadString(str);

 while(!bFind && bEnd)
 {
  if(str.Find("href=\"
http://music.xidu.net/play.asp?")>=0)
  {   
   CString temp;
   CString url;
   CString name;
   temp=str.Mid(str.Find("id=",1));
   url=temp.Left(temp.Find("\"",1));
   temp=temp.Mid(temp.Find(">",1)+1);   
   int count=temp.GetLength()-9;
   name=temp.Mid(0,count);    
   
   desfile.WriteString("mkList(\"
http://music.xidu.net/play.asp?"+url+"\", \""+name+"\");\n");   
   
  }
  else if(str.Find("The End *****")>=0)
    break;
  bEnd=file.ReadString(str);
 }
 
 file.Close();
 desfile.Close();
 AfxMessageBox("成功写入!");
 CDialog::OnOK();
}

posted on 2004-10-15 21:08  xyublog  阅读(1320)  评论(0)    收藏  举报