支持C#,Ruby,JavaScript(API)的HttpWatch 5.x


下载地址:http://www.httpwatch.com/download/
http://www.httpwatch.com/rubywatir/
对于取一些网站信息的朋友来说无疑是个好消息。
具体使用见安装后佩带的Demo
专业版支持所有,基本版就只能浏览一些基本信息


示例代码:
// Page Check C# Example
// 
// For more information about this example please refer to the readme.txt file in the
// same directory
//
using System;
using HttpWatch;

namespace page_check
{
    
class PageChecker
    {
        [STAThread]
        
static void Main(string[] args)
        {
            Console.WriteLine(
"Enter the URL of the page to check (press enter for www.microsoft.com):\r\n");
            
string url = Console.ReadLine();
            
if ( url.Length == 0 )    
                url 
= "www.microsoft.com";
            
            Console.WriteLine(
"\r\nChecking " + url + "\r\n");

            
// Create a new instance of HttpWatch in IE
            ControllerClass control = new ControllerClass();
            Plugin plugin 
= control.New();

            
// Uncomment the next line to hide the new IE window
            
// plugin.Container.Visible = false;

            
// 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();
            
            
// Look at each HTTP request in the log to compile statistics
            int roundTrips = 0, bytesReceived = 0, errors = 0, compressedSaved = 0;
            
int compressionNotChecked = 0;
            
double timeTaken = 0;
            
foreach( Entry entry in plugin.Log)
            {
                
// Keep track of last request to complete
                if ( entry.StartedSecs + entry.Time > timeTaken )
                {
                    timeTaken 
= entry.StartedSecs + entry.Time;
                }

                
if ( entry.BytesReceived != 0 )
                {
                    
++roundTrips;
                    bytesReceived 
+= entry.BytesReceived;
                }
                
if ( (entry.Error.Length != 0 && entry.Error != "Aborted"|| entry.StatusCode >= 400)
                {
                    
++errors;
                }

                
// If extended HTTP information is available
                if ( !entry.IsRestrictedURL )
                {
                    
// Calculate the compression savings
                    if ( entry.Content.IsCompressed )
                    {
                        compressedSaved 
+= entry.Content.Size - entry.Content.CompressedSize;
                    }
                }
                
else
                {
                    
++compressionNotChecked;
                }
            }
            
// Close down IE
            plugin.Container.Quit();

            Console.WriteLine( 
"Total time to load page (secs):      " + timeTaken);
            Console.WriteLine( 
"Number of bytes received on network: " + bytesReceived);

            Console.WriteLine( 
"HTTP compression saving (bytes):     " + compressedSaved);
            Console.WriteLine( 
"Number of round trips:               " + roundTrips);
            Console.WriteLine( 
"Number of errors:                    " + errors);

            
if ( control.IsBasicEdition && compressionNotChecked != 0)
            {
                Console.WriteLine( 
"\r\n(Compression was not checked in " + compressionNotChecked +
                                   
" requests because the URLs are not supported in HttpWatch Basic Edition)");
            }

            Console.WriteLine( 
"\r\nPress Enter to exit");
            Console.ReadLine();
        }
    }
}

http://www.zishuo.cn/Archives/HttpWatch.aspx
posted @ 2007-08-10 01:32 overred 阅读(1638) 评论(2)  编辑 收藏

  回复  引用  查看    
#1楼 2007-08-22 22:03 | ekeen      
在这一句Plugin plugin = control.New();

报下面的错误,为什么?谢谢!

未处理的“System.Runtime.InteropServices.COMException”类型的异常出现在 page_check.exe 中。

其他信息: Internet Explorer terminated (Error 1)


  回复  引用  查看    
#2楼 2007-10-13 16:13 | 管子管子 [未注册用户]
搜索引擎c#源代码@ekeen
搜索引擎c#源代码 EasySearch搜索引擎
能否提供一份源码,邮箱是cb277520@126.com
在此先行谢过

标题  
姓名  
主页
Email (只有博主才能看到) 
验证码 *  看不清,换一张
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2007-08-10 01:35 编辑过
 
另存  打印
最新IT新闻: