使用Flash DownLoad编写采集器(之突破防盗连下载音乐文件)
更新时间:2007年02月22日 00:00:00 作者:
'下载库通过该函数通知下载过程中发生的错误
Private Sub FDown_Error(ByVal lIndex, ByVal lErrorCode)
On Error Resume Next
If blnDStop = True Then
FDown.bStop
End If
document.getElementById("DownState").innerText = lErrorCode
End Sub
'=============================================================================================================================================================
'FDown事件模块 结束
'=============================================================================================================================================================
' ============================================
' 根据路径获取扩展名
' ============================================
Public Function GetFileExt(ByVal FullPath)
On Error Resume Next
Dim pos, pvs
pos = InStrRev(FullPath, ".")
pvs = InStrRev(FullPath, "?") - pos
If pvs < pos Then pvs = InStrRev(FullPath, "?")
If pos > 0 Then
If pvs > 0 Then
GetFileExt = Mid(FullPath, pos, pvs)
Else
GetFileExt = Mid(FullPath, pos)
End If
End If
End Function
'=============================================================================================================================================================
'功能函数模块 开始
'=============================================================================================================================================================
'下载远程URL数据
Function Download_Text(ByVal MetHod, ByVal Url, ByVal Charset, ByVal Async, ByVal Referer, ByVal Cookie)
On Error Resume Next
If Referer = "" Then Referer = Url
FDown.Init
FDown.DownLoadType = 1
FDown.MetHod = MetHod
FDown.Url = Url
FDown.Charset = Charset
FDown.SyncMode = Async
FDown.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1)"
FDown.URLReferer = Referer
FDown.Cookie = Cookie
FDown.FailRetryTimes = 3
FDown.DownLoad
End Function
'下载远程URL文件到本地
Function Download_File(ByVal MetHod, ByVal Url, ByVal SaveFile, ByVal Async, ByVal Referer, ByVal Cookie)
'On Error Resume Next
Dim UserAgent
Dim SavePath
Dim Filename
If Referer = "" Then Referer = Url
SavePath = Mid(SaveFile, 1, InStrRev(SaveFile, "\") - 1)
Filename = Mid(SaveFile, InStrRev(SaveFile, "\") + 1, Len(SaveFile))
Select Case LCase(GetFileExt(Url))
Case ".mp3", ".wma", ".wmv", ".wav", ".avi", ".mpeg", ".mpg", ".mid"
UserAgent = "NSPlayer/10.0.0.3708 WMFSDK/10.0"
Case ".rm", ".rmvb"
UserAgent = "RMA/1.0 (compatible; RealMedia) "
Case Else
UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1)"
End Select
'If FDown.CreateFolders(SavePath & "\" & Filename) = False Then
'Download_File = False
'Exit Function
'End If
FDown.Init
FDown.DownLoadType = 0
FDown.MetHod = MetHod
FDown.Url = Url
FDown.SavePath = SavePath
FDown.Filename = Filename
FDown.SyncMode = Async
FDown.UserAgent = UserAgent
FDown.URLReferer = Referer
FDown.Cookie = Cookie
FDown.FailRetryTimes = 3
Download_File = FDown.DownLoad
End Function
'下载远程URL头部信息
Function Download_Head(ByVal MetHod, ByVal Url, ByVal Async, ByVal Referer, ByVal Cookie, ByVal SAsync)
On Error Resume Next
Dim UserAgent
If Referer = "" Then Referer = Url
DownForm.Caption = Url
Select Case LCase(GetFileExt(Url))
Case ".mp3", ".wma", ".wmv", ".wav", ".avi", ".mpeg", ".mpg", ".mid"
UserAgent = "NSPlayer/9.0.0.2991 WMFSDK/9.0 "
Case ".rm", ".rmvb"
UserAgent = "RMA/1.0 (compatible; RealMedia) "
Case Else
UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1)"
End Select
FDown.Init
FDown.DownLoadType = 1
FDown.MetHod = MetHod
FDown.Url = Url
FDown.SyncMode = Async
FDown.UserAgent = UserAgent
FDown.URLReferer = Referer
FDown.Cookie = Cookie
FDown.FailRetryTimes = 3
Download_Head = FDown.DownLoadHead(Async, SAsync)
End Function
'下载Cookie
Function Download_Cookie(ByVal MetHod, ByVal Url, ByVal Referer, ByVal UserAgent, ByVal Cookie, ByVal N)
On Error Resume Next
If Referer = "" Then Referer = Url
FDown.Init
FDown.DownLoadType = 0
FDown.MetHod = MetHod
Download_Cookie = FDown.DownloadCookie(Url,Referer,UserAgent,Cookie,N)
End Function
'开始采集
Sub StartCai()
CAIType = "C1"
Download_Text 0, document.getElementById("SpecialURL").value, "gb2312", False, "", ""
End Sub
'下载音乐
Sub GetMusic()
If MusicPtr>MusicCount Then
MsgBox "全部下载完成!"
Exit Sub
End If
MusicPlayer = "http://www.520music.com/play/" & MusicURLArr(MusicPtr) & ".htm"
Download_Text 0, MusicPlayer, "gb2312", False, "", ""
End Sub
</Script>
<br />
<input type='button' value=' 开始采集 ' onclick='StartCai()'>
</BODY>
</HTML>
相关文章
asp IsValidEmail 验证邮箱地址函数(email)
验证邮箱很多在js客户端验证了,但是那样很容易被人破了,我们在服务器上用asp进行验证的话就应该没有问题了。2010-05-05ASP不能打开注册表关键字错误 ''80004005''的解决方法
这篇文章主要介绍了ASP不能打开注册表关键字错误 '80004005'的解决方法,感兴趣的小伙伴们可以参考一下2015-10-10
最新评论