这是一个我用来用html敏捷包抓取某些标签的方法。我使用这种方法与谷歌本地做排名。它似乎需要相当多的时间,并且需要大量的内存,有没有人有任何建议让它变得更好?在html敏捷包中加速解析
private void findGoogleLocal(HtmlNode node) {
String name = String.Empty;
//
// ----------------------------------------
if (node.Attributes["id"] != null) {
if (node.Attributes["id"].Value.ToString().Contains("panel_") && node.Attributes["id"].Value.ToString() != "panel__")
{
GoogleLocalResults.Add(new Result(URLGoogleLocal, Listing, node, SearchEngine.Google, SearchType.Local, ResultType.GooglePlaces));
}
}
if (node.HasChildNodes) {
foreach (HtmlNode children in node.ChildNodes) {
findGoogleLocal(children);
}
}
}
谢谢你的作品完美! foreach(结果中的结果x) { GoogleLocalResults.Add(x); } – 2012-04-24 18:14:12
你甚至可以使这个更简单,因为HtmlNode有一个默认可用的Id属性。所以x.Id.Contains(“panel_”)&&!x.Id ==“panel__”并且不需要检查x.Id == null。 – jessehouwing 2012-04-26 19:30:06