当前位置: 首页 > 图文教程 > 脚本技术 > DOS/BAT > 用asp.net实现 取页面中的所有链接

DOS/BAT
DOS 下的批处理文件
怎么在 DOS 下实现“软启动”?
重定向符(、)的使用
config.sys 文件的基本配置语句
备份硬盘主引导分区到一个文件中
恢复主引导分区
恢复 Windows3.2 的屏幕设置
清除电脑开机口令的方法
在 DOS 下怎样驱动光驱?
让你的脚本说话
DEBUG 命令详解
CMD 运行指令
最新万能 DOS 启动盘制作全攻略(软盘+光盘+U盘+硬盘+NTFS+应急实用工具)
DOS 命令字典
用replace实现替换正在使用的文件
黑客基础之DOS (最齐全)超强推荐
bat运行时不弹出那个黑框框的完美解决方案
收藏的比较完整的批处理教程
批处理版的SC
BAT文件语法和技巧(bat文件的编写及使用

DOS/BAT 中的 用asp.net实现 取页面中的所有链接


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-11   浏览: 59 ::
收藏到网摘: n/a

private void Page_Load(object sender, System.EventArgse)
{
//在此处放置用户代码以初始化页面
string url =http://www.ruanchen.com;
System.Net.HttpWebRequesthttpReq;
System.Net.HttpWebResponsehttpRes;
System.UrihttpURL = new Uri(url);
httpReq =(System.Net.HttpWebRequest)System.Net.WebRequest.Create(httpURL);
httpReq.Method= "GET";
httpRes= (System.Net.HttpWebResponse)httpReq.GetResponse();
httpReq.KeepAlive= false;
System.IO.StreamReadersReader = newSystem.IO.StreamReader(httpRes.GetResponseStream(),System.Text.Encoding.GetEncoding("GB2312"));
stringres = sReader.ReadToEnd();
//以下是利用正则表达式对获取的文本流进行过滤
stringstrRegex = @"<a.+?a>";
System.Text.RegularExpressions.Regexr;
System.Text.RegularExpressions.MatchCollectionm;
r = newSystem.Text.RegularExpressions.Regex(strRegex,System.Text.RegularExpressions.RegexOptions.IgnoreCase);
m =r.Matches(res);
Response.Write("该页共有"+m.Count + " 个超连接<br/>");
for (inti = 0; i < m.Count; i++)
{
Response.Write(m[i].Value+ "<br/>");
}
}