處理網頁html

<span style="font-family:
Arial, Helvetica, sans-serif;">NSoup.Nodes.Document doc = NSoup.NSoupClient.Connect("http://blog.csdn.net/dingxiaowie2013").Get();</span>
或者是自定義html,生成html頁面

NSoup.Nodes.Document doc = NSoup.NSoupClient.Parse(HtmlString);
但是很遺憾NSoup預設的是UTF-8,進行中文會有亂碼(對于編碼是UTF-8自然會正常,但是有些是GB2312的就可能有亂碼)
1.下載下傳網頁源代碼再處理

//下載下傳網頁源代碼
WebClient webClient = new WebClient();
string htmlString
= Encoding.GetEncoding("utf-8").GetString(webClient.DownloadData("http://www.baidu.com"));
NSoup.Nodes.Document doc = NSoup.NSoupClient.Parse(htmlString);
2.獲得網頁的流

//獲得網頁流
WebRequest webRequest = WebRequest.Create("http://blog.csdn.net/dingxiaowei2013");
NSoup.Nodes.Document doc1 = NSoup.NSoupClient.Parse(webRequest.GetResponse().GetResponseStream(), "utf-8");
會發現跟百度的源碼是一樣的
==================== 迂者 丁小未 CSDN部落格專欄=================
Unity QQ群:375151422,858550,6348968 cocos2dx QQ群:280818155
====================== 互相學習,共同進步 ===================