string strUrl = "http://tw.yahoo.com/";
string strHtml = string.Empty;

WebRequest request = WebRequest.Create(strUrl);
WebResponse response = request.GetResponse();

HttpWebResponse httpWebResponse = (HttpWebResponse)response;
//這裡取得所使用的編碼
string charSet = httpWebResponse.CharacterSet;
Encoding code = Encoding.GetEncoding(charSet);

StreamReader sr = new StreamReader(response.GetResponseStream(), code);
strHtml = sr.ReadToEnd();

只是單純代碼而已。

arrow
arrow
    全站熱搜

    souts 發表在 痞客邦 留言(1) 人氣()