Link to home
Start Free TrialLog in
Avatar of mtriviso
mtriviso

asked on

Sending Username and Password Info To Web Site

I am working on an application that visits a web site, parses the html looking for images, and downloads images above a certain size threshold.

The application works fine on any web site that does not require a username and a password.

What I want to do now is provide an interface to the user that allows them to enter the url of the web site they wish to visit, and optionally, the username and password to access the site. The username and password information can appear in several guises.

The most common is to provide a dialog box that requests this information. The next most common method is to display the username and password field on the web page itself. The third most common is the First Virtual (FV) ID which is composed of a single entry field displayed on the web page.

What I most need to know is how to submit the username and password when the web site requests it using the most common of the above methods; that of the dialog box.

I need to do this within my VB app. The urls and their associated usernames and passwords are stored on a table in the database. When the site is visited, the username and password will be retrieved and submited to the web site upon request. This will allow the user to visit a pay website, grab the images, and log off as quickly as possible. They do not have to sit at the keyboard or do anything else save for providing the url, the username, and the password.

Any help in solving this problem would be greatly appreciated.

Regards,
Mike Trivisonno
Avatar of waty
waty
Flag of Belgium image

You have to use the SenKeys Method

   SendKeys UserName & "{TAB}"  
   SendKeys Password & "{TAB}"
Avatar of mtriviso
mtriviso

ASKER

I need to have more information than that.

For example, how do I detect when the web site is requesting this information? I need to know how to detect when the username and password are requested before I can use the SendKeys method.

Also, the iNet Control provides a username and password property. And I assume I would be using this instead of the SendKeys.

If you have done this sort of thing in the past, an example would be greatly appreciated.

Thanks,
Mike
The username and password from Inet are used to connect by FTP. If you browse on FTP site, that's right.

By the way, I don't have any idea on how you could detect when you need to send username and password. I think you should create a collection of URL associated with username and password.
Ok.

That's what I really need to know: how to detect when the web site is asking for the username and password. In fact, this web site uses the dialog box method. Imagine writing a VB app that would be able to provide the username and password to log you on to Expert Exchange. That's what I need to do.

But, thanks for your input anyway.
1. What happens if you provide UID and PWD in advance?

2. You should be able to detect that dialog box within VB and fill up appropriately.
1. The uid and pwd are stored on a table in the database. So they will be known in advance.

2. This is the problem. How do I detect that web site has requested the browser to display a dialog box? How do I detect that event provide the uid and pwd.

I have a method:
Public Sub Inet1_StateChanged(ByVal State As Integer)

It is in this method that I will need to trap the event. What I am looking to trap is the problem. States like GetPage and GetHeader are easy enough. But how to I trap the open dialog request?

Netscape, Opera, and Explorer obviously know how to trap this event. They are always displaying this uid/pwd dialog box. If these apps can do it then I figure I should be able to do it too.
That's not my problem.

My problem is detecting when the site is requesting this information in the
Public Sub Inet1_StateChanged(ByVal State As Integer)
method.

I need to know when the site is requesting this information before I can supply the uid and pwd.

When the HTTP response header indicates a 401 status, the web server is saying that you are not authorized for the request.  It should also include a "WWW-authenticate:" field.  This lets you know when you need to send authentication information.

What else do you need?
jf262028,
Please repost your rejected answer as the answer so mtriviso can award you the points.  I received the following message this morning:

jf26028 answered one of my questions correctly but I rejected his
answer.

Is it possible to award him the points?

Here is the url for the question.
https://www.experts-exchange.com/Q.10080555

Thanks,
Mike
ASKER CERTIFIED SOLUTION
Avatar of jf26028
jf26028

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial