采集URL地址
我获取到了网页的源文件,想找出网页中符合我要求的URL地址
URL:http://product.dangdang.com/product.aspx?product_id=20658937
http://product.dangdang.com/product.aspx?product_id=20679355
类似这样的地址,如果我写入限制条件为product_id那么我就是想获取含有product_id这个的所有URL地址,并且不能
重复。
那样我的正则表达式应该怎么写?
我这里有获取所有URL的方法。
public string GetHref(string HtmlCode)
{
string MatchVale = "";
string Reg = @"(h|H)(r|R)(e|E)(f|F) *= *('|"")?((\w|\\|\/|\.|:|-|_)+)('|""| *|>)?";
foreach (Match m in Regex.Matches(HtmlCode, Reg))
{
MatchVale += (m.Value).ToLower().Replace("href=", "").Trim() + "||";
}
return MatchVale;
}