Hi guys, I know this is my first post and I'm asking for help. Sorry, nevertheless. I am trying to make an application that without using a web browser to do it for me will input data for me instead of having to go to the website :-) Not because I'm lazy but because I would like to do it.
Here is what I have got:
NOTE: I have edited the postData string from my correct credentials and changed the website :P
Basically at the moment it is just logging in and reporting to the RichTextBox1 the page.
What I need to do:
Make it navigate to "http://website.net/hub.php" without logging out
Input numbers into a field (already know how to do this)
___
All help is appreciated, thanks guys!
Here is what I have got:
Code:
Imports System.Net
Imports System.Text
Imports System.IO
Public Class userlogin
Dim logincookie As CookieContainer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim postData As String = "username=nouser&password=nopass&loginBtn=Login"
Dim tempCookies As New CookieContainer
Dim encoding As New UTF8Encoding
Dim byteData As Byte() = encoding.GetBytes(postData)
Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create("http://website.net/login.php"), HttpWebRequest)
postReq.Method = "POST"
postReq.KeepAlive = True
postReq.CookieContainer = tempCookies
postReq.ContentType = "application/x-www-form-urlencoded"
postReq.Referer = "http://website.net/login.php"
postReq.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0"
postReq.ContentLength = byteData.Length
Dim postreqstream As Stream = postReq.GetRequestStream()
postreqstream.Write(byteData, 0, byteData.Length)
postreqstream.Close()
Dim postresponse As HttpWebResponse
postresponse = DirectCast(postReq.GetResponse(), HttpWebResponse)
tempCookies.Add(postresponse.Cookies)
logincookie = tempCookies
Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
Dim thepage As String = postreqreader.ReadToEnd
RichTextBox1.Text = thepage
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
WebBrowser1.DocumentText = RichTextBox1.Text
End Sub
End Class
Basically at the moment it is just logging in and reporting to the RichTextBox1 the page.
What I need to do:
Make it navigate to "http://website.net/hub.php" without logging out
Input numbers into a field (already know how to do this)
___
All help is appreciated, thanks guys!