问题主旨:技术交流需求:用一句表达式,就能匹配出网站上所有的链接,即匹配出url地址和标题。
例如:网页中有
……<a href='a.htm>abc</a>……匹配后得到的结果:
链接: a.htm
标题:abc请以www.sina.com.cn或news.sina.com.cn网站为例。
运行你的程序后,就能取出网站上可以抓取得到的所有链接。如果你是牛人,就请用你的牛刀!杀头大牛,给大家看。
例如:网页中有
……<a href='a.htm>abc</a>……匹配后得到的结果:
链接: a.htm
标题:abc请以www.sina.com.cn或news.sina.com.cn网站为例。
运行你的程序后,就能取出网站上可以抓取得到的所有链接。如果你是牛人,就请用你的牛刀!杀头大牛,给大家看。
@"<a[\s\S]*?href=(""(?<href>[^""]*)""|'(?<href>[^']*)'|(?<href"
+ @">[^>\s]*))[^>]*?>(?<title>[\s\S]*?)</a>",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
两个html页面放在一起,一共匹配了2416个,而</a>一共有2417个,不知道落下了哪一个^_^
Description: This regex will extract the link and the link title for every a href in HTML source. Useful for crawling sites. Note that this pattern will also allow for links that are spread over multiple lines.
Matches: [<a href='http://www.regexlib.com'>Text</a>], [<a href="...">Text</a>]
Non-Matches: [all other html tags]
发现fancyf(凡瑞)好有空啊呵呵~~
好像我每次来都看得到
典型的水土不服^_^
fancyf(凡瑞)老哥,怎还不睡呢?
能否把你测试的源码给我测试一下,我这面不知是什么原因,匹配出来的东西,很少。