[C#] 纯文本查看 复制代码 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->private void ThreadWebBrowser(string url)
{
Thread tread = new Thread(new ParameterizedThreadStart(BeginCatch));
tread.SetApartmentState(ApartmentState.STA);
tread.Start(url);
}
private void BeginCatch(object obj)
{
string url = obj.ToString();
WebBrowser wb = new WebBrowser();
wb.ScriptErrorsSuppressed = true;
//在这里Navigate一个空白页面
wb.Navigate("about:blank");
string htmlcode = GetHtmlSource(url);
wb.Document.Write(htmlcode);
//执行分析操作 ……(略)
}
//WebClient取网页源码
private string GetHtmlSource(string Url)
{
string text1 = "";
try
{
System.Net.WebClient wc = new WebClient();
text1 = wc.DownloadString(Url);
}
catch (Exception exception1)
{}
return text1;
} |