run.bat
c:\windows\syswow64\cscript.exe http.vbs
pause
http.vbs
Function SaveHtml(p_name, p_body)
On Error Resume Next
Dim ado
Set ado = CreateObject("ADODB.Stream")
ado.Mode = adModeReadWrite
ado.Type = adTypeBinary
ado.Open
ado.Write p_body
ado.SaveToFile p_name, adSaveCreateOverWrite
End Function
Public Function URLEncode(strURL)
Dim msc
Set msc = CreateObject("MSScriptControl.ScriptControl")
msc.AllowUI = False
msc.Language = "JSCRIPT"
msc.AddCode "test=encodeURIComponent(""" & strURL & """);"
URLEncode = msc.Eval("test")
End Function
Function SaveTxt(p_name, p_contents)
dim fso, f
set fso = CreateObject("Scripting.FileSystemObject")
set f = fso.CreateTextFile(p_name, true) '第二个参数表示目标文件存在时是否覆盖
'f.Write("写入内容")
f.WriteLine(p_contents) '写入内容并换行
'f.WriteBlankLines(3) '写入三个空白行(相当于在文本编辑器中按三次回车)
f.Close()
End Function
Function http(url)
On Error Resume Next '随后的程序即便出现"运行时错误"时,也不会显示"出错信息",并且会继续运行下去.
Dim winhttp
Set winhttp = CreateObject("WinHttp.WinHttpRequest.5.1")
winhttp.open "GET", url, False
'winhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
'winhttp.Option(6) = 0
winhttp.Send
winhttp.WaitForResponse
'WSH.Echo Time& url
'WSH.Echo Time& winhttp.ResponseText
http=Time& url '函数返回值
End Function
WSH.Echo Date&" "& Time&" 程序开始"
Do While True
WSH.Echo http("http://wjsou.com")
If True Then
Exit Do
'Else
'WSH.Echo Time&" else"
End If
Loop
WSH.Echo Date&" "& Time&" 程序结束"