2008/3/18 19:39 |
閱讀數 : 7751
我要推薦
|
| 文章分類 :
.NetFramework
ASP.Net
C#
WindowForm
訂閱
-
// 模擬 IE 6.0
-
WebClient wc = new WebClient ( );
-
wc.Headers.Add ( "Accept", "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*" );
-
wc.Headers.Add ( "Accept-Language", "zh-TW" );
-
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)" );
-
Stream s = wc.OpenRead (url);
-
StreamReader sr = new StreamReader (s, Encoding. UTF8 );
-
string result = sr.ReadToEnd ( );
|
利用 WebClient 類別,並加入一些 Header 就可以騙過一些網站,讓 Web Server 信以為真是真正的使用者來訪,而非 Web Spider。
DotBlogs Tags:
.NetFramework
ASP.NET
C#
chhuang
WindowForm
關連文章
Resharper 讓 Web Service 也有 Intellisense
C# - 擷取視窗影像並另存新檔
C# 計算差異天數
ZedGraph
C# - 利用 Gmail SMTP 幫你寄信
C# - 影像處理
C# 使用 Win32 API
C# - 操作外部程式視窗
C# - 控制螢幕 Monitor Control
C# 練習題 (6)