Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Automating Website Log In

6 views
Skip to first unread message

Jason C. Lamb

unread,
Nov 30, 2009, 9:38:55 AM11/30/09
to
I am trying to automate getting some data from a website that requires
the user to login to access their data. I have the following code
which opens the page and sets the username and password, but I am
having trouble submitting the form.

I am not sure that even setting the username/password values is
working correctly, because if I step through the code, and manually
enter a value in the username field, then have the code below update
that to the correct user name, then click in the edit box, the
previous manual data returns... Strange...

Any one have any ideas how to properly submit this form so I can
authenticate?

Thanks....
Jason

Dim objIE As New SHDocVw.InternetExplorer 'Microsoft Internet
Controls
Dim objDOM As HTMLDocument 'Micosoft HTML Object Library
Dim txtField As HTMLInputTextElement
Dim btnLogin As HTMLButtonElement

objIE.Visible = True

objIE.Navigate2 "http://agencyfuel.zywave.com"

Do While objIE.ReadyState <> READYSTATE_COMPLETE
DoEvents
Loop

Set objDOM = objIE.Document

Set txtField = objDOM.all
("dnn_ctr616_View_ctl01_UsernameTextBox_text")
txtField.Value = "MyUserName"

Set txtField = objDOM.all
("dnn_ctr616_View_ctl01_PasswordTextBox_text")
txtField.Value = "MySecretPassword"

Set btnLogin = objDOM.all("dnn_ctr616_View_ctl01_LoginButton")
btnLogin.click

'objDOM.forms(0).submit

rob^_^

unread,
Dec 12, 2009, 1:07:51 PM12/12/09
to
objIE.Navigate2
"http://agencyfuel.zywave.com?dnn_ctr616_View_ctl01_UsernameTextBox_text=MyUserName&dnn_ctr616_View_ctl01_PasswordTextBox_text=MySecretPassword",,
{use the post method})


What Development Environment are you using. An ASP language would not use
the webbrowser control to submit the form post.

Regards.

"Jason C. Lamb" <jason...@gmail.com> wrote in message
news:6754ab8a-3c94-4df6...@m33g2000vbi.googlegroups.com...

Bob Barrows

unread,
Dec 12, 2009, 1:34:47 PM12/12/09
to

You would likely be better off using xmlhttp to directly request the data
from the page that the html form submits to.

--
Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Mark McGinty

unread,
Dec 28, 2009, 10:00:53 AM12/28/09
to

"Jason C. Lamb" <jason...@gmail.com> wrote in message
news:6754ab8a-3c94-4df6...@m33g2000vbi.googlegroups.com...
>I am trying to automate getting some data from a website that requires
> the user to login to access their data. I have the following code
> which opens the page and sets the username and password, but I am
> having trouble submitting the form.
>
> I am not sure that even setting the username/password values is
> working correctly, because if I step through the code, and manually
> enter a value in the username field, then have the code below update
> that to the correct user name, then click in the edit box, the
> previous manual data returns... Strange...
>
> Any one have any ideas how to properly submit this form so I can
> authenticate?

If you add a WebBrowser control to a form, instead of declaring it, you'll
be able to see the effects of your code.

Also, why are you polling readystate in a tight loop, process the
DocumentComplete event instead.


-MM

Jason C. Lamb

unread,
Jan 7, 2010, 8:03:52 AM1/7/10
to
I am currently writing this in VBA.
My goal is pull some data from this site for local processing.

On Dec 12 2009, 1:07 pm, "rob^_^" <iecustomi...@hotmail.com> wrote:
> objIE.Navigate2
> "http://agencyfuel.zywave.com?dnn_ctr616_View_ctl01_UsernameTextBox_te...",,

Jason C. Lamb

unread,
Jan 7, 2010, 8:05:04 AM1/7/10
to
I'll have to give this a shot. I don't have any experience with
xmlhttp. I'll hunt for some examples.

Thanks,

On Dec 12 2009, 1:34 pm, "Bob Barrows" <reb01...@NOyahoo.SPAMcom>
wrote:

Jason C. Lamb

unread,
Jan 7, 2010, 8:09:33 AM1/7/10
to
On Dec 28 2009, 10:00 am, "Mark McGinty" <mmcgi...@spamfromyou.com>
wrote:

>
> If you add a WebBrowser control to a form, instead of declaring it, you'll
> be able to see the effects of your code.
>
> Also, why are you polling readystate in a tight loop, process the
> DocumentComplete event instead.
>
> -MM

I show the browser... IE.Visible=True, so I can see what is happening
when I execute the click method of the submit button.

Once I get some working code I can move to event/state processing.

Thanks,
Jason

0 new messages