C# 获取当前网页HTML
//引用COM组件
//Microsoft HTML Object Library
//Microsoft Internet Controls
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();
string filename;
foreach (SHDocVw.InternetExplorer ie in shellWindows)
{
filename = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
if (filename.Equals("iexplore"))
{
SetText(string.Format("Web Site : {0}", ie.LocationURL));
mshtml.IHTMLDocument2 htmlDoc = ie.Document as mshtml.IHTMLDocument2;
SetText(string.Format(" Document Snippet: {0}",
((htmlDoc != null) ? htmlDoc.body.outerHTML
: "***Failed***")));
SetText(string.Format("{0}{0}", Environment.NewLine));
}
}