Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello Programmers,
this is my first question at code project site and I wish I could get an answer - my best programmer friend suggested this site to me as the best - and I'm searching for a solution for;
I need to get selected data from an external web page...
I've tried by fetching the desired page source code and I could do that by the following code:
...
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;

...
        private void BtnGetSc_Click(object sender, EventArgs e)
        {
            string url = TbUrl.Text;

            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
            HttpWebResponse res = (HttpWebResponse)req.GetResponse();

            StreamReader sr = new StreamReader(res.GetResponseStream());

            RtbSC.Text = sr.ReadToEnd();
            sr.Close();
        }
...


but I'm stuck in converting this source code to a C# controls, so any suggestion??!

Hint: in outher words; I need to read any web page and fetch a text box value from it.
thanks in advance for any reply :)
Posted

Welcome to Code Project, your friend is obviously very wise. :)

You can't create a C# control from the page contents since is the rendered HTML output of that control. How it is created could be any number of ways.

If you want the value of a control you can use a Regular Expression to parse the page elements or use something like this Parsing HTML Tags in C#[^]
 
Share this answer
 
Thanks Mark it is really great article but I\ve found a youtube video helps me so much and I'm just want to share it:
"Creating a Web Scraper Part 1 - C# C Sharp Visual Studio 2008"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900