VBScript脚本代码(page_check.vbs文件内容):
' Page Check VBScript Example ' ' For more information about this example please refer to the readme.txt file in the ' same directory ' WScript.Echo(vbCrLf & "Enter the URL of the page to check (press enter for www.httpwatch.com):" & vbCrLf) Dim url url = WScript.StdIn.ReadLine if Len(url) = 0 then url = "www.httpwatch.com" end if WScript.Echo( vbCrLf & "Checking " & url & "..." & vbCrLf) ' Create a new instance of HttpWatch in IE Dim control Set control = CreateObject("HttpWatch.Controller") Dim plugin Set plugin = control.IE.New ' Start Recording HTTP traffic plugin.Log.EnableFilter false plugin.Record ' Goto to the URL and wait for the page to be loaded plugin.GotoURL url control.Wait plugin, -1 ' Stop recording HTTP plugin.Stop if plugin.Log.Pages.Count <> 0 then WScript.Echo("") WScript.Echo("Page Title: '" & plugin.Log.Pages(0).Title & "'") ' Display summary statistics for page Dim summary Set summary = plugin.Log.Pages(0).Entries.Summary WScript.Echo( "Total time to load page (secs): " & summary.Time) WScript.Echo( "Number of bytes received on network: " & summary.BytesReceived) WScript.Echo( "HTTP compression saving (bytes): " & summary.CompressionSavedBytes) WScript.Echo( "Number of round trips: " & summary.RoundTrips) WScript.Echo( "Number of errors: " & summary.Errors.Count) end if ' Close down IE plugin.CloseBrowser WScript.Echo( vbCrLf & "Press Enter to exit") WScript.StdIn.ReadLine |
JavaScript脚本代码(page_check.js文件内容):
// Page Check Javascript Example // // For more information about this example please refer to the readme.txt file in the // same directory // WScript.Echo("\nEnter the URL of the page to check (press enter for www.httpwatch.com):\n"); var url = WScript.StdIn.ReadLine(); if ( url.length == 0 ) url = "www.httpwatch.com"; WScript.Echo("\nChecking " + url + "...\n"); // Create a new instance of HttpWatch in IE var control = new ActiveXObject('HttpWatch.Controller'); var plugin = control.IE.New(); // Start Recording HTTP traffic plugin.Log.EnableFilter(false); plugin.Record(); // Goto to the URL and wait for the page to be loaded plugin.GotoURL(url); control.Wait(plugin, -1); // Stop recording HTTP plugin.Stop(); if ( plugin.Log.Pages.Count != 0 ) { WScript.Echo( "\nPage Title: '" + plugin.Log.Pages(0).Title + "'"); // Display summary statistics for page var summary = plugin.Log.Pages(0).Entries.Summary; WScript.Echo( "Total time to load page (secs): " + summary.Time); WScript.Echo( "Number of bytes received on network: " + summary.BytesReceived); WScript.Echo( "HTTP compression saving (bytes): " + summary.CompressionSavedBytes); WScript.Echo( "Number of round trips: " + summary.RoundTrips); WScript.Echo( "Number of errors: " + summary.Errors.Count); } // Close down IE plugin.CloseBrowser(); WScript.Echo( "\r\nPress Enter to exit"); WScript.StdIn.ReadLine(); |