WebRequest request = WebRequest.Create("http://google.com/");//Type url here
using (WebResponse response = request.GetResponse())
{
using (StreamReader responseReader =
new StreamReader(response.GetResponseStream()))
{
string responseData = responseReader.ReadToEnd();
string path= Server.MapPath(".");
if(!File.Exists(path+"//Asptrick.html"))
File.Create(path+"//Asptrick.html");
using (StreamWriter writer =
new StreamWriter(path + "//Asptrick.html")) //Where You Want to save Content
{
writer.Write(responseData);
}
}
}
use namespace for this as following:
using System.IO;
using System.Net;
using (WebResponse response = request.GetResponse())
{
using (StreamReader responseReader =
new StreamReader(response.GetResponseStream()))
{
string responseData = responseReader.ReadToEnd();
string path= Server.MapPath(".");
if(!File.Exists(path+"//Asptrick.html"))
File.Create(path+"//Asptrick.html");
using (StreamWriter writer =
new StreamWriter(path + "//Asptrick.html")) //Where You Want to save Content
{
writer.Write(responseData);
}
}
}
use namespace for this as following:
using System.IO;
using System.Net;
Its Interesting.............
ReplyDeleteits really helpful for me amit.
ReplyDeleteCheck out http://arachnode.net. :)
ReplyDeleteCheckout the webcrawler created using java here ( using crawler4j )
ReplyDeletehttp://www.buggybread.com/2013/01/create-your-own-email-and-image.html
I have tried using the same code.. but not getting the html content..can you help.
ReplyDeleteYes Sure jeneesh Kumar i can help you.
ReplyDeletePlease Change E:\Asptrick.html this path where you want to save Html
I am gettting syntax error on using keyword.
ReplyDeletei get error server does no exist
ReplyDelete