On Error Resume Next
SourceURL = inputbox( _
vbcrlf "提取完成后您將收到一個提示。這個過程中" vbcrlf _
vbcrlf "請耐心等待,文件結(jié)果保存在:ed2k.txt" vbcrlf _
vbcrlf "請輸入鏈接地址:" vbcrlf, "Get ED2K Link", "http://" _
)
IF SourceURL = "" or SourceURL = "http://" Then
MsgBox "鏈接地址不能為空!", 48, "Get ED2K Link"
Wscript.Quit(1)
End If
'獲取網(wǎng)頁源碼
Set ObjHttp = CreateObject("Microsoft.XMLHTTP")
ObjHttp.Open "Get", SourceURL, false
ObjHttp.Send
SourceCode = Split(CodeConver(ObjHttp.responsebody), chr(10))
'分析網(wǎng)頁源碼
For i = 0 To UBound(SourceCode)-LBound(SourceCode)
MatchLine = InStr(SourceCode(i), "ed2k://|file|")
If MatchLine > 0 Then
ArrPub = Split(Replace(SourceCode(i), "},{", "}#{"), "#")
For K = 0 To UBound(ArrPub)-LBound(ArrPub)
Ed2KLink = Ed2KLink Split(Split(ArrPub(K), ",")(5), """")(3) vbcrlf
Next
End If
Next
'保存結(jié)果
If Ed2KLink = "" Then
MsgBox "該網(wǎng)頁中找不到任何 ed2k 連接!", 48, "Get ED2K Link"
Wscript.Quit(2)
Else
Set ObjFSO = CreateObject("Scripting.FileSystemObject")
ObjFSO.OpenTextFile("ed2k.txt", 8,true).Write(Ed2KLink)
End If
MsgBox "已完成全部作業(yè)!", 64, "Get ED2K Link"
Wscript.Quit(0)
Function CodeConver(vIn)
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode H80 Then
strReturn = strReturn Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn Chr(CLng(ThisCharCode) * H100 + CInt(NextCharCode))
i = i + 1
End If
Next
CodeConver = strReturn
End Function