Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.IO
- Imports System.Net ' نستدعي فضاء الـ Net
- Imports System.Text
- Public Class Form1
- ' نقوم بكتابة Function
- ' مُخصص للإرسال فقط وتلقي الـ Response
- ' ومُعالجة البيانات المُتلقية من الموقع .
- Function SendData(ByRef username As String, ByRef password As String) As String
- Dim Request As HttpWebRequest = HttpWebRequest.Create("http://localhost/dorah/") ' هُنا نُنشئ الإتصال
- Request.Method = "POST" ' هُنا ايضا قمنا بتحديد نوع الإتصال
- Request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0"
- Request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
- Request.Headers.Add("Accept-Language: en-US,en;q=0.5")
- Request.ContentType = "application/x-www-form-urlencoded"
- Request.Referer = "http://localhost/dorah/"
- ' الان نقوم بتعريف مُتغير يحمل قيم البيانات المُرسلة .
- Dim PostData As String = "username=" & username & "&password=" & password & "&submit=%D8%AA%D8%B3%D8%AC%D9%8A%D9%84+%D8%A7%D9%84%D8%AF%D8%AE%D9%88%D9%84"
- Dim ByteArray As Byte() = Encoding.Default.GetBytes(PostData)
- Request.ContentLength = byteArray.Length
- Dim DataStream As Stream = Request.GetRequestStream()
- DataStream.Write(ByteArray, 0, ByteArray.Length)
- DataStream.Close()
- Dim Response As HttpWebResponse = Request.GetResponse()
- DataStream = Response.GetResponseStream()
- Dim Reader As New StreamReader(DataStream)
- Dim ResponseFromServer As String = Reader.ReadToEnd
- Return ResponseFromServer
- End Function
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- Dim Response As String = SendData(TextBox1.Text, TextBox2.Text) ' قُمنا بإستدعاء الفنكشن وايضا وضع المتطلبات حسب قيم مربع النصوص التالي
- MsgBox(Response, MsgBoxStyle.Information, "Information")
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement