用IHTMLDocument2接口获取页面上想要的数据,代替正则表达式

原文发布时间为:2010-07-01 —— 来源于本人的百度文章 [由搬家工具导入]

1. 用 IHTMLDocument2::all 获得所有元素;
2. 用 IHTMLElementCollection::tags 获得标签为 span 的元素;
3. 用 IHTMLElement::className 获得 class 名为 EX 的元素;
4. 用 IHTMLElement::innerText 获得文本。

IHTMLDocument2 doc = new HTMLDocumentClass();
doc.write(new object[] { ie.OutString });
doc.close();
if (doc != null)
{
IHTMLElementCollection iec = (IHTMLElementCollection)doc.all.tags("dd");

foreach (IHTMLElement ii in iec)
{
if (ii.getAttribute("onmouseout", 0).ToString() != "")
{
Console.WriteLine(ii.innerText);
string str = ii.innerText;
}
}
}
原文地址:https://www.cnblogs.com/handboy/p/7164005.html