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)运行 

    完成!

  • 相关阅读:
    RN-Android构建失败:Caused by: org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'AwesomeProject'.
    Android更新包下载成功后不出现安装界面
    真机调试: The application could not be installed: INSTALL_FAILED_TEST_ONLY
    react native 屏幕尺寸转换
    Android Studio生成签名文件,自动签名,以及获取SHA1和MD5值
    React Native安卓真机调试
    git提交代码报错Permission denied, please try again
    The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.
    命令行设置快捷命令
    Linux 常用指令
  • 原文地址:https://www.cnblogs.com/ArRan/p/2767725.html
Copyright © 2011-2022 走看看