vb.net获取web验证码在winform中显示的简单示例
Private Sub GetImage()
Try
Dim request As HttpWebRequest = WebRequest.Create("http://www.junjv.com/GetImage")
request.Timeout = 20000
request.ServicePoint.ConnectionLimit = 100
request.ReadWriteTimeout = 30000
request.Method = "GET"
Dim response As HttpWebResponse = request.GetResponse()
If (response.StatusCode <> HttpStatusCode.OK) Then
Exit Sub
End If
Dim resStream As Stream = response.GetResponseStream()
PictureBox1.Image = New Bitmap(resStream) '这个是winform中的控件
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Try
Dim request As HttpWebRequest = WebRequest.Create("http://www.junjv.com/GetImage")
request.Timeout = 20000
request.ServicePoint.ConnectionLimit = 100
request.ReadWriteTimeout = 30000
request.Method = "GET"
Dim response As HttpWebResponse = request.GetResponse()
If (response.StatusCode <> HttpStatusCode.OK) Then
Exit Sub
End If
Dim resStream As Stream = response.GetResponseStream()
PictureBox1.Image = New Bitmap(resStream) '这个是winform中的控件
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
这个只是获取,就这样获取之后,是没什么用的,因为没有获取对应cookie,所以只能是显示一下