Question How can I access webpage text data and store it within a text block in my .WPF?


New member
Nov 8, 2014
Programming Experience
Hello, I am very new to C# and coding in general. I wanted to connect to a commonly used website/webpage: IMDB, Avengers 2 and essentially take some text from that page, store it within a string, and then print that out within a text block.

So I gave it a go, you'll probably cringe but oh well:

 private void Button_Click(object sender, RoutedEventArgs e)        {
            WebClient client = new WebClient();
            String downloadedString = client.DownloadString("");
           //On button enter, show Window1. 
            Window1 win1 = new Window1();

            win1.TextBlock1.Text = downloadedString; 

I have a button on the mainpage, clicking it opens up a new page with the textblock in it.

I'm using all the default .WPF namespaces and then 'using System.Net; ' as well. What happens is the client (I guess) returns the HTML code and stores that within the downloadedString variable, but this is of course not what I want. How can I say that I need the actual text from the webpage and then if you're feeling extra charitable, how can I specify which text segments I need (probably have to reference HTML or something.) I'll continue looking into this, please don't just spit out some code for me to copy and paste, that's not what I want - I learn nothing from it truly. Instead, if you could point me in the general direction of useful methods etc. For me to use, that'd be great.

Thanks guys, sorry if this post is in the wrong section.
Top Bottom