Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
Set fso = CreateObject("Scripting.FileSystemObject")
http.Option(6) = False
Set fin = fso.OpenTextFile(file,1)
Set fout= fso.OpenTextFile(file&"_ok.txt",2,1)
WScript.Echo "开始处理,请骚等、、", vbCrLf
While Not fin.AtEndOfStream
url = fin.ReadLine
If url<>"" Then ret=getUrl(url) Else ret=""
If ret<>"" Then
If InStr(ret,"app/go/url.php?") Then ret = Mid(ret,44) '需特殊处理t.cn网址
't.cn分多类情况,我没全面测试,如果出现错误,这行特殊处理代码删掉即可
WScript.Echo url, "=>", ret
fout.WriteLine ret
End If
Wend
fin.Close
fout.Close
Function getUrl(url)
On Error Resume Next
If LCase(Left(url,7))<>"http://" Then url = "http://" & url
http.Open "GET", url, False
http.Send
If Err Then
WScript.Echo url, "解析遇到错误、、"
Err.Clear
getUrl = ""
Else
getUrl = http.GetResponseHeader("Location")
End If
End Function
Function CmdMode(title, color)
If LCase(Right(WScript.FullName,11)) = "wscript.exe" Then
CreateObject("Wscript.Shell").Run "cmd /c title " & title & "&color " & color & "&Cscript //Nologo """ & WScript.ScriptFullName & """"
WScript.Quit
End If
End Function