I need something like that for VS 2003. As much as I like VS, I hate the way MS uses upward compatibility. Basically all I want to do is learn how to programmatically fill in fields on a webpage from within my application.
Here I am attempting a login attempt on a website. (username text box = edit_username)
So far:
VB Code:
Dim CookieContainer As New CookieContainer Dim strPost As String = "edit_username=my_username&edit_password=my_password" Dim myWriter As StreamWriter Dim objRequest As HttpWebRequest = CType(WebRequest.Create(uiURL.Text), HttpWebRequest) Dim cookies As CookieContainer = New CookieContainer 'objRequest.AllowWriteStreamBuffering = True objRequest.Method = "POST" objRequest.ContentType = "application/x-www-form-urlencoded" objRequest.CookieContainer = cookies myWriter = New StreamWriter(objRequest.GetRequestStream()) myWriter.Write(strPost) myWriter.Close() Dim objResponse As HttpWebResponse = CType(objRequest.GetResponse(), HttpWebResponse) Dim str As StreamReader str = New StreamReader(objResponse.GetResponseStream) uiInfo.Text = str.ReadToEnd myWriter.Close() objRequest.GetResponse().Close()
Thanks.




Reply With Quote