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

DOS/BAT
在远程计算机的CMD内下载FTP文件的方法
推荐一篇批处理最完整人性化教程
用批处理实现auto.exe的免疫功能
[原创]服务器应用自动重新启动IIS批处理
命令行实现MAC与IP地址绑定 ip mac绑定 如何绑定mac地址
diskcopy 命令使用说明
arp病毒 防止arp病毒的批处理
del rd命令行下删除文件不需要确认
dos下用recover修复损坏的TXT文件
批处理设置windows服务器的代码ThecSafe1.9.4
[原创]服务器常用批处理代码
利用mshta调用运行js或vbs的
DOS命令 Interlnk、Intersvr命令使用说明
dos shutdown 关机命令
systeminfo 系统命令快速查看你的系统几岁了
批处理删除空文件夹
BAT加密工具 EncryBat 非编译型bat批处理加密方案与代码
SendTo增强版 批处理实用小工具
DNS批量溢出批处理代码
修改系统用户名的批处理代码

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-11   浏览: 65 ::
收藏到网摘: 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/>");
}
}