|
DailyCoding > Windows
|
How to crawl a web page/file in a .net application
|
| Explains how we can crawl a web page or file using a virtual path and store the response locally |
|
Author
admin on
May 23, 2008 |
3 Comments
|
| Rate it |
|
(Rated
4
by
1
people)
|
 |
Loading.. |
|
465 Views
|
|
|
Crawling refers to request the web page data and get the reponse data programmatically.
You can easily do this in .net. Here is the daily code for this
// Be sure to include these namespaces
using System.Net;
using System.IO;
...
...
WebRequest request = WebRequest.Create("http://www.dailycoding.com/");
using (WebResponse response = request.GetResponse())
{
using (StreamReader responseReader =
new StreamReader(response.GetResponseStream()))
{
string responseData = responseReader.ReadToEnd();
using (StreamWriter writer =
new StreamWriter(@"C:\DailyCoding.html"))
{
writer.Write(responseData);
}
}
}
|
|
ASP.NET
|
C#
|
Web
|
|
|
|
|
|
|
Leave a Comment
|
 |
Loading.. |
|
|
|
|
|