leontager Posted December 25, 2003 Posted December 25, 2003 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??? Quote
*Experts* Bucky Posted December 25, 2003 *Experts* Posted December 25, 2003 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 Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
leontager Posted December 25, 2003 Author Posted December 25, 2003 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 :-) Quote
*Experts* Bucky Posted December 26, 2003 *Experts* Posted December 26, 2003 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. Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
leontager Posted December 26, 2003 Author Posted December 26, 2003 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 Quote
leontager Posted December 26, 2003 Author Posted December 26, 2003 oh never mind i got it. All i had to do is add values for the checkboxes too. Thank you very much Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.