0

Hi
I want to display the html content of the web pages(url address) in a c# window applications, but it is possible to get the dynamic content of a web pages also.

If yes please query your comment.

7
Contributors
6
Replies
22
Views
7 Years
Discussion Span
Last Post by nathanmannar
0

Try code

private string GetHtmlFromUrl(string url)
    {
        string html = "";
        HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
        
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        // get the response stream.
        //Stream responseStream = response.GetResponseStream();
        // use a stream reader that understands UTF8
        StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
        html = reader.ReadToEnd();
        // close the reader
        reader.Close();
        response.Close();
        return html;//return conten html
    }
0

If you just want to display the webpage as it appears in your browser then the WebBrowser control is the easiest way to go. You jsut set the URL and it works like any other webbrowser, but its a control embedded in your program.

0

If you just want to display the webpage as it appears in your browser then the WebBrowser control is the easiest way to go. You jsut set the URL and it works like any other webbrowser, but its a control embedded in your program. this Click Here

0

in C# WebResponse return a StreamReader and we can get the content from StreamReader ..

            WebResponse webresponse ;
            webRequest = WebRequest.Create(textBox1.Text);
            webresponse = webRequest.GetResponse();
            inStream = new StreamReader(webresponse.GetResponseStream());
            textBox2.Text = inStream.ReadToEnd();

full source code...Get URL Content

Nathan

Edited by nathanmannar: y

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.