WebRequest webRequest = WebRequest.Create("验证码url");
WebResponse webResponse = webRequest.GetResponse();
Stream stream = webResponse.GetResponseStream();
string cookie = webResponse.Headers.Get("Set-Cookie");
Image img = Bitmap.FromStream(stream);
pictureBox1.Image = img;
using (MemoryStream ms1 = new MemoryStream())
{
img.Save(ms1, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] arr1 = new byte[ms1.Length];
ms1.Position = 0;
ms1.Read(arr1, 0, (int)ms1.Length);
ms1.Close();
textBox1.Text = Convert.ToBase64String(arr1);
}
因为要做验证码识别第三方接口对接 需要将图片转换为base64传递参数 记录一下