C# 抓取页面中的所有链接
来源:互联网 发布:电影系统推荐算法 编辑:程序博客网 时间:2024/04/27 15:04
由于在最近的一个项目中,涉及到对页面的链接的抓取。以下是我总结的一些代码,现贴出来与大家分享 :
List<String> titles = new List<string>();
List<String> urls = new List<string>();
String html=null;
String p = @"<a[sS]*?href=(""(?<url>[^""]*)""|'(?<url>[^']*)'|(?<url>[^>s]*))[^>]*?>(?<title>[sS]*?)</a>";
Regex reg = new Regex(p, RegexOptions.IgnoreCase | RegexOptions.Compiled);
MatchCollection ms = reg.Matches(html);
foreach (Match m in ms)
...{
titles.Add(m.Groups["title"].Value);
urls.Add(m.Groups["url"].Value);
}
List<String> urls = new List<string>();
String html=null;
String p = @"<a[sS]*?href=(""(?<url>[^""]*)""|'(?<url>[^']*)'|(?<url>[^>s]*))[^>]*?>(?<title>[sS]*?)</a>";
Regex reg = new Regex(p, RegexOptions.IgnoreCase | RegexOptions.Compiled);
MatchCollection ms = reg.Matches(html);
foreach (Match m in ms)
...{
titles.Add(m.Groups["title"].Value);
urls.Add(m.Groups["url"].Value);
}
- C# 抓取页面中的所有链接
- 取页面中的所有链接
- 页面抓取特定链接
- .net 抓取网页所有链接
- 抓取网页中的链接
- 抓取网页中的链接
- 抓取网页中的链接
- 获取页面所有链接
- 获取页面所有链接
- PHP获取指定URL页面中的所有链接
- PHP代码:获取指定URL页面中的所有链接
- PHP 给页面内容中的所有图片添加特定链接
- PHP 获取指定URL页面中的所有链接
- C#获取远程网页中的所有链接URL
- C#获取远程网页中的所有链接URL
- C#获取远程网页中的所有链接URL
- Python抓取网页中的链接
- C#抓取页面数据汇总
- ubuntu7.10-amd64上mplayer及中文字幕
- 40个网站制作技巧
- 三一七事变——Windows 与 Linux 的纠缠
- PHP - Manual手册 - 附录 Q. PHP 类型比较表 - 表 Q.2. 用 == 进行松散比较
- Delphi中获取某类的祖先类及其所在单元名称
- C# 抓取页面中的所有链接
- sybase 导出图片到txt文件
- 《深入理解Linux内核》课程考试题目
- C#获取页面的HTML源码
- 正则表达式中的特殊字符一览
- 关于NFS的在嵌入式开发中的使用
- C# 设置应用程序开机自动运行
- 解决MySQL中文乱码
- Hidden Programs in Windows XP