惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
WordPress大学
WordPress大学
N
Netflix TechBlog - Medium
宝玉的分享
宝玉的分享
V
Visual Studio Blog
S
Securelist
P
Palo Alto Networks Blog
A
Arctic Wolf
T
Tor Project blog
P
Proofpoint News Feed
I
InfoQ
博客园 - 三生石上(FineUI控件)
T
Threat Research - Cisco Blogs
G
GRAHAM CLULEY
M
MIT News - Artificial intelligence
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Security Blog
Microsoft Security Blog
MongoDB | Blog
MongoDB | Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Apple Machine Learning Research
Apple Machine Learning Research
S
Secure Thoughts
Cyberwarzone
Cyberwarzone
Blog — PlanetScale
Blog — PlanetScale
Simon Willison's Weblog
Simon Willison's Weblog
博客园 - 【当耐特】
大猫的无限游戏
大猫的无限游戏
腾讯CDC
Latest news
Latest news
Project Zero
Project Zero
V
Vulnerabilities – Threatpost
Y
Y Combinator Blog
S
SegmentFault 最新的问题
Schneier on Security
Schneier on Security
C
CERT Recently Published Vulnerability Notes
W
WeLiveSecurity
罗磊的独立博客
Stack Overflow Blog
Stack Overflow Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
L
LINUX DO - 热门话题
N
News and Events Feed by Topic
PCI Perspectives
PCI Perspectives
C
Cisco Blogs
Application and Cybersecurity Blog
Application and Cybersecurity Blog
爱范儿
爱范儿
T
The Exploit Database - CXSecurity.com
The Last Watchdog
The Last Watchdog
人人都是产品经理
人人都是产品经理
GbyAI
GbyAI
Know Your Adversary
Know Your Adversary
U
Unit 42

博客园 - Kevin Wu

你是否也爱车 Asp..net 页面间跳转方法 Windows Server 2008 RC0正式发布、下载 如何生成静态页面的五种方案 (转)怎样用dos入侵局域网 闲里偷忙 [导入]学习网页制作: 用CSS来控制网页背景 (转)解决AJAX中使用UpdatePanel后再用Response.Write();等无法弹出对话框问题 3法 为你的aspx页面加上ajax enable - Kevin Wu 几种保持页面状态信息的讨论(转) 在Windows Servrer 2003下安装UDDI服务和UDDI .NET SDK JDK1.5+Tomcat5+MySql+Juddi 架设UDDI服务器 拒绝了对对象 'xp_cmdshell'(数据库 'master',所有者 'dbo')的 EXECUTE 权限 解决方法 无法将类型“ASP.login_aspx”转换为“System.Web.UI.WebControls.Login” 错误处理 终于考完试了~~~ 远程控制(3) 远程控制(2) 关于windows hook的提问 远程控制(1)
通过Url抓取网页内容
Kevin Wu · 2007-09-20 · via 博客园 - Kevin Wu

近来想学习一下网页抓取技术,监于之前没有这方面的基础,都只是在socke方面的编程,对http方面了解很少,现在到个较好的入门例子,共享学习一下,如果大家以前看过的话,就当是复习吧。还希望高手可以指导一下如何学习这方面的内容,给点指引。

using System;
using System.Text;
using System.Web;
using System.IO;
using System.Net;public string ReadUrlContent(string rUrl) 
{
// used to build entire input
StringBuilder sb  = new StringBuilder();//用于作为读取内容操作的缓冲区
byte[]        buf = new byte[8192];// 请求该页面
HttpWebRequest  request  = (HttpWebRequest)
 WebRequest.Create(rUrl);
// 获取返回的数据(通过相应)
HttpWebResponse response = (HttpWebResponse)
 request.GetResponse();
//将读取到的数据放入到流里面
Stream resStream = response.GetResponseStream();string tempString = null;
int totalcount = 0;
int    count      = 0;
FileStream fs 
= File.Create(Server.MapPath("urltext.html"));do
{
 
//读取部分的数据
 count = resStream.Read(buf, 0, buf.Length);//确定读取的数据不为空
 if (count != 0)
 {
  
//转换内容格式byte 到 ascii
  tempString = Encoding.ASCII.GetString(buf, 0, count);
  fs.Write(buf,
0,count);//写入文件
  
//加入到字符串
  sb.Append(tempString);
 }

 totalcount 

+= count;
}
while (count > 0);

resStream.Close();
fs.Close();

return sb.ToString();

}

通过这些内容,初步了解了如何通过Url获取单个网页的内容,可以在这些内容的基础上进行分析,获取更多的url,这些就是后话了。
代码地址:http://www.mending.cn/ibook/doc.aspx?uid=17&cid=884&did=6215