'本程序仅供参考,请勿用于非法用途
Dim strId As String = "lishewen"
Dim strPassword As String = "123456"
'定义编码器
Dim encoding As New ASCIIEncoding()
Dim postData As String = "userid=" + strId
postData += ("&password=" + strPassword)
Dim data As Byte() = encoding.GetBytes(postData)
'获得HttpWebRequest对象
Dim myRequest As HttpWebRequest = DirectCast(WebRequest.Create("http://www.lishewen.com/login.asp"), HttpWebRequest)
myRequest.Method = "POST"
myRequest.ContentType = "application/x-www-form-urlencoded"
myRequest.ContentLength = data.Length
Dim newStream As Stream = myRequest.GetRequestStream()
'发送数据
newStream.Write(data, 0, data.Length)
newStream.Close()
'接收返回信息
Dim myResponse As HttpWebResponse = DirectCast(myRequest.GetResponse(), HttpWebResponse)
Dim reader As New StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.[Default])
Dim content As String = reader.ReadToEnd()
Console.WriteLine(content)
Dim strId As String = "lishewen"
Dim strPassword As String = "123456"
'定义编码器
Dim encoding As New ASCIIEncoding()
Dim postData As String = "userid=" + strId
postData += ("&password=" + strPassword)
Dim data As Byte() = encoding.GetBytes(postData)
'获得HttpWebRequest对象
Dim myRequest As HttpWebRequest = DirectCast(WebRequest.Create("http://www.lishewen.com/login.asp"), HttpWebRequest)
myRequest.Method = "POST"
myRequest.ContentType = "application/x-www-form-urlencoded"
myRequest.ContentLength = data.Length
Dim newStream As Stream = myRequest.GetRequestStream()
'发送数据
newStream.Write(data, 0, data.Length)
newStream.Close()
'接收返回信息
Dim myResponse As HttpWebResponse = DirectCast(myRequest.GetResponse(), HttpWebResponse)
Dim reader As New StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.[Default])
Dim content As String = reader.ReadToEnd()
Console.WriteLine(content)