Question parse data web site

thierno

New member
Joined
Nov 18, 2019
Messages
3
Programming Experience
Beginner
I'm a beginner in C# and I've just started a new project. It consists in retrieving data from a website of an internal application of my company. I wanted to know if there is less than to retrieve the data (the DOM tree) from an Internet Explorer page opened in C# . without knowing the address ( the link, nor the title). I used several techniques (HtmlAgilityPack, CallBackPtr and EnumWindows) without success.
 
What's so special about this Ie window?

Who navigates the Ie window?

How will you determine what is the correct page if you don't know the title or url?

Why don't you just use web requests to pull whatever needed data is required? I spent 3 years at a company who had exactly this type of silly setup and like I told them, I advised against it. They didn't listen, and they ended up with an immense amount of problems. Problems which could have been avoided had they taken a different route.
 
to retrieve the data (the DOM tree) from an Internet Explorer page opened in C# . without knowing the address ( the link, nor the title)
Say what? If the IE page was open in C#, that means that the C# code knows what the URL is. How else would you open the IE page?
 
For the (the DOM tree) part, I assumed they meant the source code as you would view it in the inspector, but that's anyone's guess if I'm right. As for the later, I have no idea.

This is the trouble with poorly asked questions, and I can only blame Stack overflow for that, as they started this trend...
 
What's so special about this Ie window?

Who navigates the Ie window?

How will you determine what is the correct page if you don't know the title or url?

Why don't you just use web requests to pull whatever needed data is required? I spent 3 years at a company who had exactly this type of silly setup and like I told them, I advised against it. They didn't listen, and they ended up with an immense amount of problems. Problems which could have been avoided had they taken a different route.


thanks for your answer
do you know a instance of web request that allows you to extract these types of data ?
 
You don't get the data from the HttpWebRequest. You get it from the HttpWebResponse. Specifically by reading the stream returned by HttpWebResponse.GetResponseStream(). If that is to low level for you, then you can also use the WebClient.OpenRead() to get the stream instead. You then pass that stream into the HtmlAgilityPack to do the hard job of doing the parsing and getting you back a DOM.
thanks for your post
I abandoned the idea of htmlAgilityPack because I can't modify or interact with the DOM tree (dynamically add fields, submit the form by clicking)

But I still don't know the best way to proceed.
 
Or even simpler would be to only use WebClient.DownloadString

C#:
        private void Dwnstr(string adr)
        {
            WebClient wc = new WebClient();
            string res = wc.DownloadString(adr);
            Console.WriteLine(res);
        }
 
I can't modify or interact with the DOM tree (dynamically add fields, submit the form by clicking)
Come again?

Submit form?

Ok, It's time to explain what you're actually doing in detail, because if you are trying to interact with a webpage, and submit a form, getting the contents isn't going to be much use to you here.
 
I abandoned the idea of htmlAgilityPack because I can't modify or interact with the DOM tree (dynamically add fields, submit the form by clicking)
What?!?!?! The title of your topic is "parse data web site". Parsing is different from manipulating or interacting. As Sheepings said, you need to explain in detail what you are trying to do. Tell us what you are trying to achieve instead of how you are trying to achieve it.
 
Back
Top Bottom