int timeoutSeconds = 1;
// 設定request
System.Net.WebRequest request = System.Net.WebRequest.Create(URL);
//設定TimeOut的時間(怕網路速度過慢,資料不完全)
request.Timeout = timeoutSeconds * 1000;
// 從request接收資料
System.Net.WebResponse response = request.GetResponse();
System.IO.Stream streamReceive = response.GetResponseStream(); System.Text.Encoding encoding = System.Text.Encoding.GetEncoding("utf-8"); System.IO.StreamReader streamRead = new System.IO.StreamReader(streamReceive, System.Text.Encoding.Default);
// 取得原始碼
String HTML = streamRead.ReadToEnd();
沒有留言:
張貼留言