手揣网教程:绿色安全纯净官方版,体验当今速度最快的浏览器!

后台遍历一个HTML页面

时间:2024/12/16作者:未知来源:手揣网教程人气:

[摘要]前几天写一个程序,需要后台遍历一个动态生成的页面,找寻特定节点于是写了以下代码: public class HtmlReader public HtmlReader() /// /...
前几天写一个程序,需要后台遍历一个动态生成的页面,找寻特定节点

于是写了以下代码:

public class HtmlReader
{
public HtmlReader()
{
}
///
/// 搜索特定标记的节点
///
///
///
/// 返回属性值数组
public static ArrayList SearchAttributes(string inMarkup, string KeyWord, string AttrName)
{
IHTMLDocument2 doc = new HTMLDocumentClass ();
doc.write (new object [] {inMarkup});
doc.close ();
ArrayList searchList = new ArrayList();

foreach(IHTMLElement el in (IHTMLElementCollection)doc.body.all)
{
if(el.tagName.ToLower() ==KeyWord)
{
string src=el.getAttribute(AttrName,0).ToString();
//src=src.Remove(0,src.LastIndexOf("/")+1);
searchList.Add(src);
}
}
return searchList;
}

}





关键词:后台遍历一个HTML页面




Copyright © 2012-2018 手揣网教程(http://www.shouchuai.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版