Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function Request(url As String, data As String)
- Dim vystup As String = Nothing
- Try
- 'Our postvars
- Dim buffer As Byte() = System.Text.Encoding.ASCII.GetBytes(data)
- 'Initialisation, we use localhost, change if appliable
- Dim WebReq As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
- 'Our method is post, otherwise the buffer (postvars) would be useless
- WebReq.Method = "POST"
- 'We use form contentType, for the postvars.
- WebReq.ContentType = "application/x-www-form-urlencoded"
- 'The length of the buffer (postvars) is used as contentlength.
- WebReq.ContentLength = buffer.Length
- 'We open a stream for writing the postvars
- Dim PostData As Stream = WebReq.GetRequestStream()
- 'Now we write, and afterwards, we close. Closing is always important!
- PostData.Write(buffer, 0, buffer.Length)
- PostData.Close()
- 'Get the response handle, we have no true response yet!
- Dim WebResp As HttpWebResponse = DirectCast(WebReq.GetResponse(), HttpWebResponse)
- 'Now, we read the response (the string), and output it.
- Dim Answer As Stream = WebResp.GetResponseStream()
- Dim _Answer As New StreamReader(Answer)
- 'Congratulations, you just requested your first POST page, you
- 'can now start logging into most login forms, with your application
- 'Or other examples.
- vystup = _Answer.ReadToEnd()
- Return vystup.Trim() + vbLf
- Catch ex As Exception
- End Try
- End Function
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- IO.File.WriteAllText("hh.html", Request("http://force-generator.de/register.php", "username=gaylegsbian&password=mgama&confirmpassword=mgama&email=Farl81951%40jourrapide.com"))
- Process.Start("hh.html")
- End Sub
Add Comment
Please, Sign In to add comment