Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi, i've been browsing around and I found the following code someone else wrote

 

 

Dim ITEM As Object

Dim obIE As SHDocVw.InternetExplorer

Dim obDC As mshtml.HTMLDocument

 

obIE = New SHDocVw.InternetExplorer()

obIE.Navigate("URL")

obIE.Visible = True

While obIE.Busy : Application.DoEvents() : End While

 

obDC = obIE.Document

Do Until obDC.readyState = "complete"

Application.DoEvents()

Loop

 

For Each ITEM In obDC.all.tags("input")

'Fill in the username textbox

If ITEM.Name = "username" Then ITEM.Value = "username"

'Fill in the password textbox

If ITEM.Name = "password" Then ITEM.Value = "password"

Next

 

'Check the remember me checkbox if you wish

obDC.all.item("ipsec").Click()

'Click on Sign in

obDC.all.item("submit").Click()

While obIE.Busy : Application.DoEvents() : End While

 

 

but how can i get the source code of that window???

  • *Experts*
Posted

If you're using a .NET language, you should really be using the

WebClient class to post forms and download data.

 

But, if you insist, the source code for the WebBrowser control can

be obtained through obDC.documentElement.innerHTML

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

  • *Experts*
Posted

Sure. To "log in", you post to the form using the [mshelp=ms-help://MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfsystemnetwebclientclassuploadvaluestopic.htm]UploadValues[/mshelp]

method. There's an example following that link.

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Posted

ah...sorry again...I tried the code but for some reason it tells me that my username and password are incorrect. I tried loging in and it works fine

 

Dim uriString As String = SelectURL(2, 4)

Dim myWebClient As New WebClient()

Dim myNameValueCollection As New System.Collections.Specialized.NameValueCollection()

Dim name As String = "username"

Dim password As String = "password"

 

myNameValueCollection.Add("username", name)

myNameValueCollection.Add("password", password)

Dim responseArray As Byte() = _

myWebClient.UploadValues(uriString, "POST", myNameValueCollection)

 

 

I probably dont fully understand how to use this. There are 2 text fields on the site. one called username and other called password. There are also 2 checkboxes and a submit button. please help

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...