Search 
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)
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

Discussion

himanshu On Nov 11, 2008 09:57 AM
Hey Thank You so much, gr8 help.

himanshu On Nov 11, 2008 09:57 AM
Hey Thank You so much, gr8 help.

himanshu On Nov 11, 2008 09:57 AM
Hey Thank You so much, gr8 help.

Leave a Comment

Name
Email Address
Web Site
© Copyright 2008 Daily Coding • All rights reserved