怎么提取url

来源:百度知道 编辑:UC知道 时间:2024/07/07 13:33:04
<a href="http://www.baidu.com" title>百度</a>
<a href="http://www.google.cn" target=_blank>Google</a>
<a href="http://www.baidu.com" title>百度</a>
<a href="http://www.google.cn" target=_blank>Google</a>

根据我输入的开始代码:<a href=" 结束代码:" title 来截取 在<a href=" 与" title内的url 用c# 怎么实现?

使用HTMLDocument类精心拆解
HtmlDocument htmlDocument=new HtmlDocument();
获取htmlDocument.Links属性即所有的连接
之后通过正则验证哪些是所需要的提取出来
类似于 <a href="http://www.google.cn" target=_blank>Google</a>
之后使用方法获取href属性的值就是 http://www.google.cn