.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

How to read the text from index of webpage

Posted By: Ramesh     Posted Date: August 11, 2010    Points:2   Category :ASP.Net
Hi,

I am using this code
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(conn);
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
Stream receiveStream = myHttpWebResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
StreamReader readStream = new StreamReader(receiveStream, encode);
Text = readStream.ReadToEnd();

but this is read the html code form webpage, i want to read the index of webpage(plain text) could u pleeas help me

Responses
Author: Syed Shakeer Hussain             
Posted Date: August 11, 2010     Points: 5   

Hi,
use the following Code:

WebRequest request = WebRequest.Create("http://www.fryan0911.com/2009/08/how-to-read-web-page-using-c.html");
using (WebResponse response = request.GetResponse())
{
using (StreamReader responseReader =
new StreamReader(response.GetResponseStream()))
{
string responseData = responseReader.ReadToEnd();
using (StreamWriter writer =
new StreamWriter(@"C:\SaveResponse\sample.html"))
{
writer.Write(responseData);
}
}
}




Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend