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

DOS/BAT
为cmd设置密码的批处理
把下一行的数字复制到前面一行的后面,并用空格分开的批处理
批处理 保留空行替换字符串
批处理 文件归类整理器
批处理 文件归类整理器(当面目录)
批处理 删除重复行的代码
批处理 字符串去空格实现代码[不同部位]
去掉字符串头所有的0的批处理
反序列出文本的每行内容的批处理
反序显示输入内容批处理
把多行文本拼接成用;连接的一行的批处理
把某个目录下所有txt中第三行第四个数字相加
把首行和尾行互换的批处理
拼接相临的奇偶行文本内容
把两个文件中的不同之处提取到某个文件中去
显示只有指定个数字符的行
显示某两个字符及之间的字符
显示随机的5个数
查找偶数行内容的批处理
查找行中的第一个数据串

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


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