程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> ASP編程 >> 關於ASP編程 >> asp實現的7xi音樂網的采集源代碼

asp實現的7xi音樂網的采集源代碼

編輯:關於ASP編程
共5個文件:
2個是配置文件:
配置文件:
cfg.txt '---保存檢測ID信息的,第一次采集時設為1,從小到大檢測
cfg.asp '---ASP的配置信息,內容如下:
復制代碼 代碼如下:
<% 
''' 
'''╔=======================================╗ 
'''┆                                       ┆ 
'''┆ @系統: 7xi音樂采集系統 Version 2.0    ┆ 
'''┆ @模塊: 配置文件                       ┆ 
'''┆ @創建: 2006/07/24                     ┆ 
'''┆ @作者: D.S.Fang                       ┆ 
'''┆ @聯系: [email protected] QQ-3700909    ┆ 
'''┆ @版權: 源碼公開,無任何版權問題,您可以 ┆ 
'''┆        放心使用!!!尊重作者勞動成果,請 ┆ 
'''┆        保留此信息!                    ┆ 
'''┆                                       ┆ 
'''╚=======================================╝ 
''' 

dim picc_FolderPath,mp3_FolderPath 
dim v_7xijs_url,v_7xipicc_url,v_7xiplay_url,v_7xialbum_url,v_7ximp3_url,cfg_name,cfg_line 
dim httpobj,str,str0,str1,str2,str3,str4,str5,str6,str7,str8,str9 
dim is_getrm 

'---音樂文件是否保存到本地,true-保存;false-不保存 
is_getrm = false 

'---保存路徑 
picc_FolderPath = "H:\mp3data\images\" 
mp3_FolderPath = "H:\mp3data\rm\"  

'---7xi相關頁面 
v_7xijs_url = "http://7xi.net/player/Js.js" 
v_7xipicc_url = "http://ww.7xi.net/picc/" 
v_7xiplay_url = "http://7xi.net/playsong/" 
v_7xialbum_url = "http://ww.7xi.net/Vo2/" 
v_7ximp3_url = "" '---實時讀取 

'---檢測ID 
cfg_name = "cfg.txt"  
cfg_line = 1  

'---讀取播放js文件,獲得rm文件路徑 
set httpobj = server.createobject("paopao.http") 
str = httpobj.get(v_7xijs_url) 
str0 = split(str,"theurl2="&chr(34)) 
str1 = split(str0(1),chr(34)) 
v_7ximp3_url = str1(0) 
set httpobj = nothing 
str = "" 

'---數據庫連接 
set Conn = Server.CreateObject("ADODB.Connection")  
Conn.Open "driver={SQL server};server=localhost;uid=mp3;pwd=mp3;database=mp3db"  

'---拼SQL語句execute時需要過濾一下 
Function IndbStr(str) 
        if isNull(str) or str = "" then 
                IndbStr = str 
        else 
                IndbStr = replace(replace(trim(str),"'","''"),"%","") 
        end if 
End Function 

'---關閉數據庫連接 
Function CloseConn() 
        conn.close 
        set conn=nothing 
End Function 

'---取得遠程文件並保存到本地 
Function GetRemoteFiles(RemotePath, LocalPath, FileName) 
  Dim strBody 
  Dim FilePath 
  On Error Resume Next 
  '---取得流 
  strBody = GetBody(RemotePath) 
  '---取得保存的文件名 
  if Right(LocalPath, 1) <> "\" then LocalPath = LocalPath & "\" 
  if not CheckDir(bkfolder) then MakeNewsDir bkfolder 
  FilePath = LocalPath & GetFileName(RemotePath, FileName) 
  '---保存文件 
  if SaveToFile(strBody, FilePath) = true and err.Number = 0 then 
   GetRemoteFiles = true 
  else 
    GetRemoteFiles = false 
  end if 
End Function 

'---遠程獲取內容 
Function GetBody(url)  
  Dim Retrieval 
  '---建立XMLHTTP對象 
  Set Retrieval = CreateObject("Microsoft.XMLHTTP")  
  With Retrieval  
  .Open "Get", url, False, "", ""  
  .Send  
  GetBody = .ResponseBody 
  End With  
  Set Retrieval = Nothing  
End Function 

'---重組文件名 
Function GetFileName(RemotePath, FileName) 
  Dim arrTmp 
  Dim strFileExt 
  arrTmp = Split(RemotePath, ".") 
  strFileExt = arrTmp(UBound(arrTmp)) 
  GetFileName = FileName & "." & strFileExt 
End Function 

'---將流內容保存為文件 
Function SaveToFile(Stream, FilePath) 
  Dim objStream 
  On Error Resume Next 
  '---建立ADODB.Stream對象,必須要ADO 2.5以上版本 
  Set objStream = Server.CreateObject("ADODB.Stream") 
  objStream.Type = 1 '以二進制模式打開 
  objStream.Open 
  objstream.write Stream 
  objstream.SaveToFile FilePath, 2 
  objstream.Close() 
  '---關閉對象,釋放資源 
  Set objstream = Nothing 
  if err.Number <> 0 then 
    SaveToFile = false 
  else 
    SaveToFile = true 
  end if 
End Function 

'---讀取文本文件 
Function FSOlinedit(filename,lineNum) 
  if linenum < 1 then exit function 
  dim fso,f,temparray,tempcnt 
  set fso = server.CreateObject("scripting.filesystemobject") 
  if not fso.fileExists(server.mappath(filename)) then exit function 
  set f = fso.opentextfile(server.mappath(filename),1) 
  if not f.AtEndofStream then 
    tempcnt = f.readall 
    f.close 
    set f = nothing 
    temparray = split(tempcnt,chr(13)&chr(10)) 
    if lineNum>ubound(temparray)+1 then 
      exit function 
    else 
      FSOlinedit = temparray(lineNum-1) 
    end if 
  end if 
End function 

'---檢查絕對路徑是否存在 
Function CheckFolder(FolderPath) 
  dim fso1 
  Set fso1 = CreateObject("Scripting.FileSystemObject") 
  If fso1.FolderExists(FolderPath) then 
     '存在 
     CheckFolder = True 
  Else 
     '不存在 
     CheckFolder = False 
  End if 
  Set fso1 = nothing 
End Function 

'---根據指定名稱生成目錄 
Function MakeNewsDir(foldername) 
  dim fso1,f 
  Set fso1 = CreateObject("Scripting.FileSystemObject") 
  Set f = fso1.CreateFolder(foldername) 
  MakeNewsDir = True 
  Set fso1 = nothing 
End Function 

''''''''編碼(日文字符)'''''''' 
Function Jencode(byVal iStr) 
        if isnull(iStr) or isEmpty(iStr) then 
                Jencode="" 
                Exit function 
        end if 
        dim F,i,E 
        E=array("Jn0;","Jn1;","Jn2;","Jn3;","Jn4;","Jn5;","Jn6;","Jn7;","Jn8;","Jn9;","Jn10;","Jn11;","Jn12;","Jn13;","Jn14;","Jn15;","Jn16;","Jn17;","Jn18;","Jn19;","Jn20;","Jn21;","Jn22;","Jn23;","Jn24;","Jn25;") 
        F=array(chr(-23116),chr(-23124),chr(-23122),chr(-23120),_ 
        chr(-23118),chr(-23114),chr(-23112),chr(-23110),_ 
        chr(-23099),chr(-23097),chr(-23095),chr(-23075),_ 
        chr(-23079),chr(-23081),chr(-23085),chr(-23087),_ 
        chr(-23052),chr(-23076),chr(-23078),chr(-23082),_ 
        chr(-23084),chr(-23088),chr(-23102),chr(-23104),_ 
        chr(-23106),chr(-23108)) 
        Jencode=iStr 
        for i=0 to 25 
                Jencode=replace(Jencode,F(i),E(i)) 
        next 
End Function 

''''''''解碼(日文字符)'''''''' 
Function Juncode(byVal iStr) 
        if isnull(iStr) or isEmpty(iStr) then 
                Juncode="" 
                Exit function 
        end if 
        dim F,i,E 
        E=array("Jn0;","Jn1;","Jn2;","Jn3;","Jn4;","Jn5;","Jn6;","Jn7;","Jn8;","Jn9;","Jn10;","Jn11;","Jn12;","Jn13;","Jn14;","Jn15;","Jn16;","Jn17;","Jn18;","Jn19;","Jn20;","Jn21;","Jn22;","Jn23;","Jn24;","Jn25;") 
        F=array(chr(-23116),chr(-23124),chr(-23122),chr(-23120),_ 
        chr(-23118),chr(-23114),chr(-23112),chr(-23110),_ 
        chr(-23099),chr(-23097),chr(-23095),chr(-23075),_ 
        chr(-23079),chr(-23081),chr(-23085),chr(-23087),_ 
        chr(-23052),chr(-23076),chr(-23078),chr(-23082),_ 
        chr(-23084),chr(-23088),chr(-23102),chr(-23104),_ 
        chr(-23106),chr(-23108)) 
        Juncode=iStr 
        for i=0 to 25 
                Juncode=replace(Juncode,E(i),F(i))'□ 
        next 
End Function 
%> 


1個是手動添加歌手: 
addsinger.asp '---手動添加歌手,內容如下: 

 程序代碼 
<% 
''' 
'''╔=======================================╗ 
'''┆                                       ┆ 
'''┆ @系統: 7xi音樂采集系統 Version 2.0    ┆ 
'''┆ @模塊: 手動添加歌手                   ┆ 
'''┆ @創建: 2006/07/24                     ┆ 
'''┆ @作者: D.S.Fang                       ┆ 
'''┆ @聯系: [email protected] QQ-3700909    ┆ 
'''┆ @版權: 源碼公開,無任何版權問題,您可以 ┆ 
'''┆        放心使用!!!尊重作者勞動成果,請 ┆ 
'''┆        保留此信息!                    ┆ 
'''┆                                       ┆ 
'''╚=======================================╝ 
''' 
'%> 
<!--#include file="cfg.asp" --> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<meta http-equiv="Content-Language" content="gb2312" /> 
<title>添加歌手分類_7xi音樂采集更新系統</title> 
</head> 
<body> 
<br>7xi音樂采集更新系統<br><br> 
<% 
dim sql 
dim singer_name,singer_first_name,singer_sort 

singer_name = IndbStr(request("singer_name")) 
singer_first_name = Ucase(IndbStr(request("singer_first_name"))) 
singer_sort = request("singer_sort") 

response.write "<br>歌手信息<br><br>姓名:"&singer_name&"<br>字母:"&singer_first_name&"<br>性質:"&singer_sort 

sql = "insert into d_singer (singer_name,singer_first_name,singer_sort,is_down) values ('"&singer_name&"','"&singer_first_name&"','"&singer_sort&"',0)" 
response.write "<br><br>"&sql 
conn.execute(sql) 
CloseConn() 

'---歌手添加完成後轉入信息采集重新檢測 
response.write "<br><br>歌手信息檢查添加完成,正在准備檢查獲取更新...<br>" 
response.write "<meta http-equiv=refresh content=""1 ; url=get.asp"">" 
%> 
</body> 
</html> 


2個是采集程序: 
get.asp '---采集歌手專輯歌曲信息,內容如下 

 程序代碼 
<% 
''' 
'''╔=======================================╗ 
'''┆                                       ┆ 
'''┆ @系統: 7xi音樂采集系統 Version 2.0    ┆ 
'''┆ @模塊: 歌手、專輯、歌曲信息采集       ┆ 
'''┆ @創建: 2006/07/24                     ┆ 
'''┆ @作者: D.S.Fang                       ┆ 
'''┆ @聯系: [email protected] QQ-3700909    ┆ 
'''┆ @版權: 源碼公開,無任何版權問題,您可以 ┆ 
'''┆        放心使用!!!尊重作者勞動成果,請 ┆ 
'''┆        保留此信息!                    ┆ 
'''┆                                       ┆ 
'''╚=======================================╝ 
''' 
'%> 
<!--#include file="cfg.asp" --> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<meta http-equiv="Content-Language" content="gb2312" /> 
<title>歌手專輯歌曲信息采集_7xi音樂采集更新系統</title> 
</head> 
<body> 
<br>7xi音樂采集更新系統<br><br> 
<% 
dim t7xiid,url,FolderPath,fso,fout 
dim songid(100),songname(100) 
dim strsinger,strlang,stralbum,strtime,strcorp,strcontent,strpicc,singerid,albumid 
dim rssort,rssinger,rsalbum,rssong,i,m,sql,okimg 

t7xiid = FSOlinedit(cfg_name,cfg_line) 

url = v_7xialbum_url&"v_"&t7xiid&".htm" 

set httpobj=server.createobject("paopao.http") 

Err.Clear 
'on error resume next 

str = "" 
str = httpobj.get(url) 

if str = "" then 
        CloseConn() 
  if t7xiid < 3198 then '---沒有檢測到時是否遞增ID,繼續檢測 
    str = t7xiid + 1 
    FolderPath = Server.MapPath(".\") 
    Set fso = Server.CreateObject("Scripting.FileSystemObject") 
    Set fout = fso.CreateTextFile(FolderPath & "\cfg.txt")  
    fout.WriteLine str 
    fout.close  
    response.write "<br>當前ID號不存在,正在檢查下一ID號 ...<br>" 
    response.write "<meta http-equiv=refresh content=""0 ; url=get.asp"">" 
  else  '---不需要遞增ID檢測時,轉到歌曲信息采集 
    response.write "<br>歌手專輯信息檢查完畢,正在准備檢查獲取歌曲信息 ...<br>" 
    response.write "<meta http-equiv=refresh content=""0 ; url=getrm.asp"">" 
    response.end 
  end if 
else 
  str0 = split(str,"歌 手 : ") 
  str1 = split(str0(1),"</td>") 
  strsinger = IndbStr(str1(0)) 
  response.write "<br>歌手:"&strsinger 

  str0 = split(str,"語 種 : ") 
  str1 = split(str0(1),"</td>") 
  strlang = str1(0) 
  response.write "<br>語種:"&strlang 

  str0 = split(str,"專 輯 : ") 
  str1 = split(str0(1),"</a>") 
  str2 = split(str1(0),""">") 
  stralbum = IndbStr(str2(1)) 
  response.write "<br>專輯:"&stralbum 

  str0 = split(str,"時 間 : ") 
  str1 = split(str0(1),"</td>") 
  strtime = str1(0) 
  response.write "<br>時間:"&strtime 

  str0 = split(str,"公 司 : ") 
  str1 = split(str0(1),"</td>") 
  strcorp = str1(0) 
  response.write "<br>公司:"&strcorp 

  str0 = split(str,"<tr valign=""top""><td colspan=""2"">") 
  str1 = split(str0(1),"</td>") 
  strcontent = replace(replace(IndbStr(str1(0)),"<br>",chr(13))," "," ") 
  response.write "<br>簡介:"&strcontent 

  str0 = split(str,"<img src=""../picc/") 
  str1 = split(str0(1),"""") 
  strpicc = str1(0) 
  response.write "<br>圖片:"&strpicc 
  response.write "<br><img src="&v_7xipicc_url&strpicc&" border=0>" 

  set rssinger = conn.execute("select * from d_singer where singer_name='"&strsinger&"'") 
  '---歌手信息不存在時需要手動添加歌手 
  if rssinger.eof then 
    response.write "<br>select * from d_singer where singer_name='"&strsinger&"'" 
    response.write "<br><br>歌手不存在,需要手動操作添加。<br><br>請按以下要求添加歌手:<br><br>" 
%> 
<form action="addsinger.asp"> 
<input type="text" size="20" name="singer_name" value="<%=strsinger%>"> 
<input type="text" size="6" name="singer_first_name" value="姓" maxlength="3"> 
<select name="singer_sort" size="1"><%'%> 
<% 
    set rssort = conn.execute("select * from s_sort ") 
    do while not rssort.eof and i < 10 
%> 
<option value="<%=rssort("id")%>"><%=rssort("sort_name")%></option><%'%> 
<% 
      rssort.movenext 
    loop 
    rssort.close 
    set rssort = nothing 
%></select> 
<input type="submit" value="添加"> 
</form> 
<%  
    CloseConn() 
    response.end 
  else  '---歌手信息已存在,檢查專輯信息是否需要入庫 
    singerid = rssinger("id") 
    conn.execute("update d_singer set is_down=0 where id="&singerid) 
    response.write "<br><br>歌手信息正確,正在檢查獲取專輯信息 ...<br>" 
    set rsalbum = conn.execute("select * from d_album where album_singer="&singerid&" and album_name='"&stralbum&"'") 
    if rsalbum.eof then 
      str1 = split(strpicc,".") 
      str2 = str1(0) 
      sql="insert into d_album (album_singer,file_img,album_name,album_lang,album_corp,album_time,album_intro,add_time,is_down,album_7xi) values ('"&singerid&"','"&strpicc&"','"&stralbum&"','"&strlang&"','"&strcorp&"','"&strtime&"','"&strcontent&"','"&now&"',0,"&t7xiid&")" 
      conn.execute(sql) 
      '---采集保存專輯縮略圖 
      okimg = GetRemoteFiles(v_7xipicc_url&strpicc,picc_FolderPath,str2)                 
      response.write "<br>專輯信息檢查添加完成,正在檢查獲取歌曲信息 ..."&"<br>SQL語句:"&sql 
    else 
      response.write "<br><br>專輯信息正確,正在准備檢查獲取歌曲信息 ..." 
    end if     
    rsalbum.close 
    set rsalbum = nothing 
  end if 
  rssinger.close 
  set rssinger = nothing 

  set rsalbum = conn.execute("select * from d_album where album_singer="&singerid&" and album_name='"&stralbum&"'") 
  albumid = rsalbum("id") 
  rsalbum.close 
  set rsalbum = nothing 

  response.write "<br><br>專輯歌曲信息<br>" 

  '----歌曲ID 
  i = 1 
  str0 = split(str,"<input type="&chr(34)&"checkbox"&chr(34)&" name="&chr(34)&"checked"&chr(34)&" value="&chr(34)) 
  response.write "<br>歌曲ID:" 
  do while i <= Ubound(str0) 
    str1 = split(str0(i),chr(34)) 
    songid(i-1) = str1(0) 
    response.write songid(i-1)&" - " 
    i = i + 1 
  loop 
  response.write "共"&i&"首。" 

  '---歌曲名稱 
  m = 1 
  str0 = split(str,"<a href=""../IVR.asp?id=") 
  response.write "<br><br>歌曲:" 
  do while m <= Ubound(str0) 
    str1 = split(str0(m),""" target=""_blank""><img src=""../images/mmsring1.gif"" alt=""免費點歌") 
    songname(m-1) = Jencode(replace(str1(0),"'","''")) 
    response.write Juncode(songname(m-1))&" - " 
    m = m + 1 
  loop 
  response.write "共"&i&"首。" 

  '---歌曲ID數目和歌曲名數目不一致時需要檢查是否有誤 
  if i <> m then 
    response.write "<br><br><font color=red><b>錯誤:</b>歌曲ID數目與歌曲名數目不一致,請檢查目標頁面:"& url &"</font>" 
    response.end 
  end if 

  '---檢查歌曲是否需要入庫 
  do while i > 1 
    set rssong = conn.execute("select * from d_mp3 where mp3_album="&albumid&" and mp3_singer="&singerid&" and mp3_name='"&songname(i-2)&"'") 
    if rssong.eof then 
      sql = "insert into d_mp3 (mp3_7xi,mp3_singer,mp3_album,mp3_name) values ('"&songid(i-2)&"','"&singerid&"','"&albumid&"','"&songname(i-2)&"')" 
      conn.execute(sql) 
      response.write "<br><font color=red>添加:"&songname(i-2)&"</font>" 
      response.write sql 
    else 
      response.write "<br>跳過:"&songname(i-2) 
    end if 
    rssong.close 
    set rssong = nothing 
    i = i-1 
  loop 

  CloseConn() 

  '---記錄下一檢測ID號 
  str = t7xiid + 1 
  FolderPath = Server.MapPath(".\") 
  Set fso = Server.CreateObject("Scripting.FileSystemObject") 
  Set fout = fso.CreateTextFile(FolderPath & "\cfg.txt")  
  fout.WriteLine str 
  fout.close 

  '---繼續檢測下一ID 
  response.write "<br>正在檢測下一ID信息 ..." 
  response.write "<meta http-equiv=refresh content=""0 ; url=get.asp"">" 
end if 
%> 
</body> 
</html> 


getrm.asp '---采集RM文件更新歌曲信息,內容如下: 

 程序代碼 
<% 
''' 
'''╔=======================================╗ 
'''┆                                       ┆ 
'''┆ @系統: 7xi音樂采集系統 Version 2.0    ┆ 
'''┆ @模塊: 歌曲文件、歌詞等信息采集       ┆ 
'''┆ @創建: 2006/07/24                     ┆ 
'''┆ @作者: D.S.Fang                       ┆ 
'''┆ @聯系: [email protected] QQ-3700909    ┆ 
'''┆ @版權: 源碼公開,無任何版權問題,您可以 ┆ 
'''┆        放心使用!!!尊重作者勞動成果,請 ┆ 
'''┆        保留此信息!                    ┆ 
'''┆                                       ┆ 
'''╚=======================================╝ 
''' 
'%> 
<!--#include file="cfg.asp" --> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<meta http-equiv="Content-Language" content="gb2312" /> 
<title>歌曲文件歌詞等信息采集_7xi音樂采集更新系統</title> 
</head> 
<body> 
<br>7xi音樂采集更新系統<br><br> 
<% 
dim getcount,rssong,id,t7xiid,url,filerm,tmpurl,i,tmpfolder,okrm,singer,song,tmp_url,lyric,rs 

'---每次處理歌曲數量 
getcount = 5 
set rssong = conn.execute("select top " & getcount & " a.*,b.singer_name from d_mp3 a,d_singer b where a.mp3_singer=b.id and a.file_rm is null order by a.id desc") 

if rssong.eof then  '---歌曲信息處理完成 
  rssong.close 
  set rssong = nothing 
  CloseConn() 
        response.write "<br>歌曲文件信息檢查采集完成!" 
        response.write "<br><br>采集完了,可以做垃圾站了!" 
        response.end 
else 
  do while not rssong.eof 
    id = rssong("id") 
    t7xiid = rssong("mp3_7xi") 
    singer = replace(rssong("singer_name")," ","%20") 
    song = replace(rssong("mp3_name")," ","%20") 
    response.write "<br><br>歌曲名 - "& singer & "-" &song 
    '---目標頁面 
    url = v_7xiplay_url&t7xiid&".htm" 
    set httpobj = server.createobject("paopao.http") 
    Err.Clear 
    on error resume next 
    response.write "<br>"&url 
    str = httpobj.get(url) 
    if Err = 0 then '---讀取目標頁面正常時的處理 
      '----歌曲文件名及文件夾 
      str0 = split(str,"<param name='src' value='"&chr(34)&"+s_list+"&chr(34)) 
      str1 = split(str0(1),"'>") 
      filerm = str1(0) 
      response.write "<br>文件名 - "& filerm  
      tmpurl = v_7ximp3_url & filerm 
      response.write "<br>目標源 - "& tmpurl 
      '---需要保存音樂文件到本地時,采集保存音樂文件 
      if is_getrm then 
        str0 = split(filerm,"/") 
        i = 0 
        do while i < Ubound(str0) 
          tmpfolder = mp3_FolderPath & str0(i) 
          if not CheckFolder(tmpfolder) then MakeNewsDir tmpfolder 
          i = i + 1 
        loop 
        response.write "<br>保存為 - "& tmpfolder & "\" & str0(Ubound(str0)) 
        okrm = GetRemoteFiles(tmpurl,tmpfolder,replace(str0(Ubound(str0)),".rm","")) 
      else 
        response.write "<br><font color=red>請注意 - </font>RM文件配置為不保存!!!!!!!!!!" 
      end if 

      '---歌詞采集 
      tmp_url = "http://www.7xi.net/showword.asp?id=" & t7xiid 
      response.write "<br>"&tmp_url 
      set httpobj = server.createobject("paopao.http") 
      str0 = httpobj.get(tmp_url) 
      Err.Clear 
      on error resume next 
      str1 = split(str0,"<td width=""92%"">"&chr(13)) 
      str2 = split(str1(1),"                </td>") 
      lyric = str2(0) 
      lyric = replace(lyric,"<br>",chr(13)) 
      lyric = replace(lyric," "," ") 
      lyric = replace(replace(lyric,"<p>",""),"</p>","") 
      lyric = IndbStr(trim(lyric)) 
      if Instr(lyric,"mp3.baidu.com") then lyric = "暫時還沒歌詞"         

      if len(lyric) < 20 or Err <> 0 then 
        lyric = "暫時還沒歌詞" 
        response.write "<br>7xi自帶歌詞不完整,將采集baidu歌詞" 
      end if 

      if lyric = "暫時還沒歌詞" then 
        Err.Clear 
        tmp_url = "http://mp3.baidu.com/m?f=ms&rn=10&tn=baidump3lyric&ct=150994944&word="&singer&"+"&song 
        response.write "<br>"&tmp_url 
        str0 = httpobj.get(tmp_url) 
        str1 = split(str0,"<B><font style=color:#e10900>"&song&"</font></B>") 
        if Ubound(str1) >= 1 then 
          str2 = split(str0,"<div style=""padding-left:10px;line-height:20px;padding-top:1px"">") 
          str3 = split(str2(1),"</div>") 
          lyric = str3(0) 
          lyric = replace(lyric,"<br>",chr(13)) 
          lyric = replace(lyric," "," ") 
          lyric = replace(lyric,"<font style=color:#e10900>","") 
          lyric = replace(lyric,"</font>","") 
        else 
          lyric = "暫時還沒歌詞" 
        end if 
      end if 

      response.write "<br>歌詞 - "&lyric 

      '---將采集到的信息更新到數據庫 
      if is_getrm then 
        conn.execute("update d_mp3 set file_rm='"&filerm&"',mp3_lyric='"&lyric&"',is_down='1' where id="&id) 
      else 
        conn.execute("update d_mp3 set file_rm='"&filerm&"',mp3_lyric='"&lyric&"',is_down='0' where id="&id) 
      end if 
    else  '---讀取目標頁面出錯時的處理 
      conn.execute("update d_mp3_t set file_rm='nourl',is_down='1' where id="&id) 
      response.write "<br><br><font color=red><b>錯誤:</b>獲取目標頁面錯誤,請檢查:"& url &"</font>" 
      response.end 
    end if 
    rssong.movenext 
  loop 
  rssong.close 
  set rssong = nothing 
  CloseConn() 

  '---繼續檢測采集下一批歌曲信息 
  response.write "<br>正在檢測下一批歌曲信息 ...<br><br>" 
  response.write "<meta http-equiv=refresh content=""0 ; url=getrm.asp"">" 
end if 
%> 
</body> 
</html> 


數據庫表的SQL腳本: 
數據庫表 

 程序代碼 
s_sort ----歌手分類表 

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[s_sort]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) 
drop table [dbo].[s_sort] 
GO 

Create TABLE [dbo].[s_sort] ( 
        [ID] [int] IDENTITY (1, 1) NOT NULL , 
        [sort_name] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL  
) ON [PRIMARY] 
GO 

Alter TABLE [dbo].[s_sort] WITH NOCHECK ADD  
        CONSTRAINT [PK_s_sort] PRIMARY KEY  CLUSTERED  
        ( 
                [ID] 
        )  ON [PRIMARY]  
GO 




d_singer ----歌手信息表 

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[d_singer]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) 
drop table [dbo].[d_singer] 
GO 

Create TABLE [dbo].[d_singer] ( 
        [ID] [int] IDENTITY (1, 1) NOT NULL , 
        [singer_name] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL , 
        [singer_first_name] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , 
        [singer_sort] [int] NULL , 
        [mp3_num] [int] NULL , 
        [is_putup] [bit] NULL , 
        [view_count] [int] NULL , 
        [is_down] [bit] NULL  
) ON [PRIMARY] 
GO 

Alter TABLE [dbo].[d_singer] WITH NOCHECK ADD  
        CONSTRAINT [PK_d_singer] PRIMARY KEY  CLUSTERED  
        ( 
                [ID] 
        )  ON [PRIMARY]  
GO 



d_album ----專輯信息表 

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[d_album]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) 
drop table [dbo].[d_album] 
GO 

Create TABLE [dbo].[d_album] ( 
        [ID] [int] IDENTITY (1, 1) NOT NULL , 
        [album_singer] [int] NULL , 
        [file_img] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL , 
        [album_name] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL , 
        [album_lang] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL , 
        [album_corp] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL , 
        [album_time] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL , 
        [album_intro] [ntext] COLLATE Chinese_PRC_CI_AS NULL , 
        [is_singer_album] [bit] NULL , 
        [view_count] [int] NULL , 
        [is_putup] [bit] NULL , 
        [add_time] [datetime] NULL , 
        [album_7xi] [int] NULL , 
        [is_down] [bit] NULL  
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] 
GO 

Alter TABLE [dbo].[d_album] WITH NOCHECK ADD  
        CONSTRAINT [PK_d_album] PRIMARY KEY  CLUSTERED  
        ( 
                [ID] 
        )  ON [PRIMARY]  
GO 




d_mp3 ----歌曲信息表 

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[d_mp3]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) 
drop table [dbo].[d_mp3] 
GO 

Create TABLE [dbo].[d_mp3] ( 
        [ID] [int] IDENTITY (1, 1) NOT NULL , 
        [mp3_name] [varchar] (200) COLLATE Chinese_PRC_CI_AS NULL , 
        [mp3_album] [int] NULL , 
        [mp3_singer] [int] NULL , 
        [file_rm] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL , 
        [file_size] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL , 
        [is_putup] [bit] NULL , 
        [mp3_lyric] [varchar] (5000) COLLATE Chinese_PRC_CI_AS NULL , 
        [view_count] [int] NULL , 
        [down_count] [int] NULL , 
        [is_my] [bit] NULL , 
        [mp3_7xi] [int] NULL , 
        [is_down] [varchar] (2) COLLATE Chinese_PRC_CI_AS NULL  
) ON [PRIMARY] 
GO 

Alter TABLE [dbo].[d_mp3] WITH NOCHECK ADD  
        CONSTRAINT [PK_d_mp3] PRIMARY KEY  CLUSTERED  
        ( 
                [ID] 
        )  ON [PRIMARY]  
GO
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved