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));
}
}
标签:htmlDoc,网页,string,Format,C#,SetText,filename,HTML,ie 来源: https://www.cnblogs.com/wdcwy/p/15737621.html