source code

leontager

Regular
Joined
Jun 17, 2003
Messages
89
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???
 
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
 
well my problem si that I have to login first, then retreive the source code. If you could show me a better way I would be very happy :-)
 
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.
 
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
 
Back
Top