On Error Resume Next
SourceURL = inputbox( _
vbcrlf "提取完成后您将收到一个提示。这个过程中" vbcrlf _
vbcrlf "请耐心等待,文件结果保存在: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
'获取网页源码
Set ObjHttp = CreateObject("Microsoft.XMLHTTP")
ObjHttp.Open "Get", SourceURL, false
ObjHttp.Send
SourceCode = Split(CodeConver(ObjHttp.responsebody), chr(10))
'分析网页源码
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
'保存结果
If Ed2KLink = "" Then
MsgBox "该网页中找不到任何 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 "已完成全部作业!", 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