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 4 Comments
Rate it    (Rated 2 by 3 people)
2,551 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.

Visual C# Kicks On Jan 13, 2009 12:16 AM
Something similar but data is downloaded in chunks (makes it possible to determine download speed and such):

http://www.vcskicks.com/download_file_http.html

Leave a Comment

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