Click to See Complete Forum and Search --> : C# Screen Scrape/Object Control


bgibilaro
August 10th, 2009, 08:47 PM
Hello All,

I have a bit of a quandry. I wanted to create windows form to scrape some data from a web app that I have an account for. I was planning on doing the standard ol' process using HttpWebRequest and was going to create the credentials in the request, blah blah blah.

Anyways, apparently, this app uses some crazy security where I have to login with one set of credentials, it creates a temporary certificate that I have to agree to and then I have to login with another set of credentials.

So my next thought was that I would write something that would actually handle the process of filling in the fields and clicking the buttons on each step of the process, etc. The problem? I have no idea how to do that, or if it is even possible.

Anyone had any experience with this? I guess it is almost like writing a macro or something, only from my code.

I would appreciate any help. Thanks!

Bob

rliq
August 11th, 2009, 01:51 AM
Bob,

The thing that comes to mind is SendKeys. This may be what you require. From the .NET documentation:

Use SendKeys to send keystrokes and keystroke combinations to the active application. This class cannot be instantiated. To send a keystroke to a class and immediately continue with the flow of your program, use Send. To wait for any processes started by the keystroke, use SendWait.

AshBrennan
August 11th, 2009, 06:51 PM
Well you'll be wanting to use the WebClient class, although if I'm correct it's really just a wrapper for common objects for the http classes. Anyway look into using the NetworkCredential class which as the name suggests sends login credentials to pages, however I'm not exactly sure how it works, however I'm sure there will be some great examples as it's a popular task.