vbs using xmlhttp
‘GetHTMLSource.vbs
args = WScript.Arguments.Count
if args <> 1 then
Wscript.Echo “usage: GetHTMLSource.vbs URL”
wscript.Quit
end if
URL = WScript.Arguments.Item(0)
Set WshShell = WScript.CreateObject(“WScript.Shell”)
Set http = CreateObject(“Microsoft.XmlHttp”)
http.open “GET”, URL, FALSE
http.send “”
WScript.Echo http.responseText
set WshShell = nothing
set http = nothing
‘HTMLHead.vbs
args = WScript.Arguments.Count
if args <> 1 then
Wscript.Echo “usage: HTMLHead.vbs URL”
wscript.Quit
end if
URL = WScript.Arguments.Item(0)
Set WshShell = WScript.CreateObject(“WScript.Shell”)
Set http = CreateObject(“Microsoft.XmlHttp”)
http.open “HEAD”, URL, FALSE
http.send “”
WScript.Echo http.getAllResponseHeaders
‘ You can display a specific header by using the getResponseHeader method:
‘ Wscript.echo http.getResponseHeader(“Content-Length”)
‘ You can use the Status and/or StatusText properties if all you want is the
‘ page status information:
‘ Wscript.echo http.Status & vbTab & http.StatusText
‘ On XP and above you could use these properties and
‘ the Win32_Ping object to ping a server to see if it’s alive
‘ and check the status of a web page to verify the web server
‘ is sending the requested page.
set http = nothing
set WshShell = nothing
‘ScrapeLinks.vbs
args = WScript.Arguments.Count
if args <> 1 then
Wscript.Echo “usage: ScrapeLinks.vbs URL”
wscript.Quit
end if
URL = WScript.Arguments.Item(0)
With CreateObject(“InternetExplorer.Application”)
.Navigate URL
Do Until .ReadyState = 4
Wscript.sleep 10
Loop
for each link in .document.links
Wscript.echo link, link.InnerText
next
‘ Uncomment the three lines below to scrape references to images
‘ for each pix in .document.images
‘ Wscript.echo pix.src
‘ next
.Quit
End With
转自: http://www.paulsadowski.com/wsh/xmlhttp.htm