Site Meter & 線上人數

tracker

部落格觀察


我的噗浪

Google Latitude

微軟認證



聯絡我 - MSN & Skype & Email



最新回應

C# 用 WebClient 模擬 IE 6.0 連線

2008/3/18 19:39| 閱讀數 : 3362 | 我要推薦 | Add Comment | 文章分類: .NetFramework ASP.Net C# WindowForm 訂閱

  1. // 模擬 IE 6.0
  2. WebClient wc = new WebClient( );
  3. wc.Headers.Add ( "Accept", "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*" );
  4. wc.Headers.Add ( "Accept-Language", "zh-TW" );
  5. wc.Headers.Add ( "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)" );
  6. Stream s = wc.OpenRead (url);
  7. StreamReader sr = new StreamReader(s, Encoding.UTF8 );
  8. string result = sr.ReadToEnd ( );

利用 WebClient 類別,並加入一些 Header 就可以騙過一些網站,讓 Web Server 信以為真是真正的使用者來訪,而非 Web Spider。

DotBlogs Tags: .NetFramework ASP.NET C# chhuang WindowForm


關連文章

標題 *
名稱 *
Email (將不會被顯示)
Url
回應
登入後使用進階評論
Please add 4 and 4 and type the answer here: