zoukankan      html  css  js  c++  java
  • C# 调用httpwatch接口基础使用方法

    (1)安装httpwatch; 

    (2)打开c#工程,在“引用”中增加“COM”组件,在“COM”组件中找到“HttpWatch Professional 7.2 Automation Libary”,确定。(7.2为我安装的httpwatch版本) 

    (3)copy代码 

    C#代码  收藏代码
    1. using System;  
    2. using HttpWatch;  
    3.   
    4. namespace page_check  
    5. {  
    6.     class PageChecker  
    7.     {  
    8.         [STAThread]  
    9.         static void Main(string[] args)  
    10.         {  
    11.             Console.WriteLine("Enter the URL of the page to check (press enter for http://www.baidu.com/):\r\n");  
    12.             string url = Console.ReadLine();  
    13.             if ( url.Length == 0 )    
    14.                 url = "http://www.baidu.com/";  
    15.               
    16.             Console.WriteLine("\r\nChecking " + url + "...\r\n");  
    17.   
    18.             // Create a new instance of HttpWatch in IE  
    19.             Controller control = new Controller();  
    20.             Plugin plugin = control.IE.New();  
    21.   
    22.             // Start Recording HTTP traffic  
    23.             plugin.Log.EnableFilter(false);  
    24.             plugin.Record();  
    25.   
    26.             // Goto to the URL and wait for the page to be loaded  
    27.             plugin.GotoURL(url);  
    28.             control.Wait(plugin, -1);  
    29.   
    30.             // Stop recording HTTP  
    31.             plugin.Stop();  
    32.   
    33.             if (plugin.Log.Pages.Count != 0)  
    34.             {  
    35.                 Console.WriteLine("\r\nPage Title: '" + plugin.Log.Pages[0].Title + "'");  
    36.   
    37.                 Console.WriteLine();  
    38.   
    39.                 // Display summary statistics for page  
    40.                 Summary summary = plugin.Log.Pages[0].Entries.Summary;  
    41.                 Console.WriteLine("Total time to load page (secs):      " + summary.Time);  
    42.                 Console.WriteLine("Number of bytes received on network: " + summary.BytesReceived);  
    43.                 Console.WriteLine("HTTP compression saving (bytes):     " + summary.CompressionSavedBytes);  
    44.                 Console.WriteLine("Number of round trips:               " + summary.RoundTrips);  
    45.                 Console.WriteLine("Number of errors:                    " + summary.Errors.Count);  
    46.   
    47.                 Console.WriteLine("-----------------------",plugin.Log.Entries.Count);  
    48.   
    49.                 //Entries e = plugin.Log.Entries;  
    50.                 for (int i=0; i<plugin.Log.Entries.Count; i++)   
    51.                 {  
    52.                     Console.Write(plugin.Log.Entries[i].URL);  
    53.                     Console.WriteLine(" " + plugin.Log.Entries[i].Time);  
    54.                 }  
    55.             }  
    56.             // Close down IE  
    57.             plugin.CloseBrowser();  
    58.   
    59.             Console.WriteLine( "\r\nPress Enter to exit");  
    60.             Console.ReadLine();  
    61.         }  
    62.     }  
    63. }  



    (4)运行 

    完成!

  • 相关阅读:
    PHP基础笔记之一
    乱码问题
    PHP函数
    取色工具ColorPix
    框架
    区别和详解:jQuery中的 $().each()和$.each()/jQuery.each()
    区别和详解:jQuery extend()和jQuery.fn.extend()
    H5基于iScroll实现下拉刷新,上拉加载更多....
    重要选择器querySelector和querySelectorAll
    微信对话框小三角形实现
  • 原文地址:https://www.cnblogs.com/ArRan/p/2767725.html
Copyright © 2011-2022 走看看