使用Flash DownLoad编写采集器(之突破防盗连下载音乐文件)第3/4页
更新时间:2007年02月22日 00:00:00 作者:
<Script Language="VBScript">
Dim IStr,StrSave,StrCookie
Dim CAIType
Dim MusicBody,MusicNameArr,MusicURLArr,MusicCount,MusicPtr,MusicName,MusicPlayer,MusicURL,MusicSave
Set IStr = CreateObject("IVVN.String")
'msgbox IStr.Version
FDown.BackColor = "#FFFFFF"
FDown.FillColor = "#FFFFFF"
FDown.FrameColor = "#E0E0E0"
'=============================================================================================================================================================
'FDown事件模块 开始
'=============================================================================================================================================================
'下载库通过该函数通知下载状态
Private Sub FDown_Status(ByVal lIndex, ByVal lStatus, ByVal bstrStatusParam)
On Error Resume Next
If blnDStop = True Then
FDown.bStop
Exit Sub
End If
document.getElementById("DownForm").innerText = FDown.Url
If FDown.DownLoadType = dtToFile And FDown.SavePath <> "" And FDown.Filename <> "" Then
document.getElementById("DownTo").innerText = FDown.SavePath & "\" & FDown.Filename
Else
document.getElementById("DownTo").innerText = "抓取数据..."
End If
Dim strMsg
strMsg = "线程" & lIndex + 1 & ":"
If lStatus = 0 Then
strMsg = strMsg & "解析域名 "
ElseIf lStatus = 1 Then
strMsg = strMsg & "获得IP地址 "
ElseIf lStatus = 2 Then
strMsg = strMsg & "连接服务器 "
ElseIf lStatus = 3 Then
strMsg = strMsg & "连接服务器成功 "
ElseIf lStatus = 4 Then
strMsg = strMsg & "重定向到 "
ElseIf lStatus = 5 Then
strMsg = strMsg & "开始接收数据 "
ElseIf lStatus = 6 Then
strMsg = strMsg & "下载结束 "
End If
strMsg = strMsg & bstrStatusParam & vbCrLf
document.getElementById("DownState").innerText = strMsg
End Sub
'下载库通过该事件通知文件下载进度
Private Sub FDown_Progress(ByVal dbFileSize, ByVal dbFinished, ByVal dbSpeed)
On Error Resume Next
If blnDStop = True Then
FDown.bStop
Exit Sub
End If
Dim BFile
Dim BRead
Dim BShare
Dim BSpeed
BFile = dbFileSize
BRead = dbFinished
BShare = dbFinished / (dbFileSize / 100)
BSpeed = dbSpeed
If IsNumeric(dbFinished) = True And IsNumeric(dbFileSize) = True Then
BFile = dbFileSize
BRead = dbFinished
BShare = dbFinished / (dbFileSize / 100)
pb.setModel(BRead/BFile)
document.getElementById("DownLoading").innerText = BRead & " of " & BFile & " transferred (" & Round(BShare, 2) & "%)"
End If
If IsNumeric(dbSpeed) = True Then
BSpeed = dbSpeed
document.getElementById("DownSpeed").innerText = "Throughput " & BSpeed & " /s"
End If
End Sub
'下载库通过该事件通知下载过程结束
Private Sub FDown_DownloadEnd(ByVal bSuccess)
On Error Resume Next
Select Case CAIType
Case "C1"
StrBody = FDown.Body
oSpecialName = IStr.RegContent(StrBody,"专辑名称:","</li>")
document.getElementById("SpecialName").value = oSpecialName
oSinGer = IStr.RegContent(StrBody,"歌手名称:","</li>")
document.getElementById("SinGer").value = oSinGer
oGongSi = IStr.RegContent(StrBody,"唱片公司:","</li>")
document.getElementById("GongSi").value = oGongSi
oYuYan = IStr.RegContent(StrBody,"专辑语种:","</li>")
document.getElementById("YuYan").value = oYuYan
oTimes = IStr.RegContent(StrBody,"发行时间:","</li>")
document.getElementById("Times").value = oTimes
oPIC = IStr.RegContent(StrBody,"<div class=""rightcolumn""><div id=""albuminfo""><img src=""",""">")
document.getElementById("PIC").value = oPIC
oremark = IStr.RegContent(StrBody,"<h2>专辑介绍</h2><p>","</p>")
document.getElementById("remark").value = oremark
StrSave = document.getElementById("SavePath").value & "\" & oSinGer & "\" & oSpecialName
CAIType = "C2"
Download_File 0, oPIC, StrSave & "\1.jpg", True, document.getElementById("SpecialURL").value, StrCookie
MusicBody = IStr.RegContent(StrBody,"<form name=form2 target=myplay action=../rd18playlist.htm>","<input name=""chkall2"" onclick=CheckAll(this.form) type=""button"" value=""全 选"" />")
MusicNameArr = IStr.RegContent(MusicBody,"<a href=""../mydown.htm?musicname=",""" target=_blank>",0,True)
MusicNameArr = Split(MusicNameArr,"§")
MusicURLArr = IStr.RegContent(MusicBody,"<input name=""checked"" type=""checkbox"" value=""",""" />",0,True)
MusicURLArr = Split(MusicURLArr,"§")
MusicCount = UBound(MusicURLArr)
CAIType = "C3"
MusicPtr = 0
GetMusic
Case "C3"
StrBody = FDown.Body
MusicURL = "http://wma7.520music.com/20060312/" & IStr.RegContent(StrBody,"document.write(""<PARAM NAME=\""URL\"" VALUE='""+url+""/","'>"")")
MusicSave = StrSave & "\" & MusicPtr+1 & IStr.GetFileExt(MusicURL)
CAIType = ""
StrCookie = Download_Text(0,"http://hi.520music.com/hi.htm", "gb2312", True, MusicPlayer, "")
StrCookie = FDown.Body
StrCookie = IStr.RegContent(StrCookie,"document.cookie=""","; domain=hi.520music.com;")
'MsgBox StrCookie
CAIType = "C4"
Download_File 0, MusicURL, MusicSave, False, document.getElementById("SpecialURL").value, StrCookie
Case "C4"
CAIType = "C3"
MusicPtr = MusicPtr + 1
GetMusic
End Select
If blnDStop = True Then
FDown.bStop
Exit Sub
End If
End Sub


最新评论