System.IO.StreamReader sr = new System.IO.StreamReader(webBrowser1.DocumentStream, Encoding.GetEncoding("gb2312"));
string html = sr.ReadToEnd();//获取源文件
sr.Close();
/*截取table 的html源文件*/
int start = html.IndexOf("<table id=\"post_tb\" width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"3\">");
int end = html.IndexOf("</table>", start) + 8;
string tbhtm = html.Substring(start, end - start);
webBrowser1.DocumentText = tbhtm;//设置为table的html代码
C#利用webBrowser怎么显示网页中只想显示的部分
本文介绍了一种使用C#从网页中抓取指定表格数据的方法。通过创建StreamReader对象读取网页源码,并采用字符串操作技术定位到所需的table标签,最后将获取到的数据重新设置为浏览器显示的内容。


被折叠的 条评论
为什么被折叠?



