views:

42

answers:

1

Hi.

I have a Java program, that opens a new browser window when I click on on a menu. The Java program requires login, so the html page has a Session ID.

I want to access this page with my C# program, so that I can extract some data from it. Unfortunately, the only way to get to this html page is through the Java client's menu, so there's no way to log in in a html form.

I'd like to get the source of this html page automatically, so I thought about somehow redirecting the event that opens a new browser window if the link starts like my required page.

Another option is to change the default browser to my program before clicking the menu programmatically, and restore the original default browser afterwards.

I know that these ideas may be quite ugly, and there may be much simpler solutions, but I'm a beginner in C#, and I've never done anything like this, so I'd really appreciate any help on how to solve this problem.

Thanks in advance.

A: 

Java isn't using black magic to open the browser window. Most certainly, it just takes the url and "executes" it or it uses the desktop API. In either case, the Java program just uses HTTP protocol and you can do the same in C#.

So instead of trying to hack the OS, install a proxy which allows you to see the HTTP headers and then run the Java program once to figure out what it does. Try http://www.privoxy.org/ which is pretty easy to set up.

Then use the standard HTTP library of C# to do the same.

Aaron Digulla