C# winform 获取网页的图片验证码,并显示

2019-04-15 18:36发布

  C#获取网页的验证码,并且显示在 picbox控件上 view plaincopy to clipboardprint?
  1. HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://127.0.0.1/pic/Default.aspx");
  2. request.Timeout = 20000;
  3. request.ServicePoint.ConnectionLimit = 100;
  4. request.ReadWriteTimeout = 30000;
  5. request.Method = "GET";
  6. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  7. if (response.StatusCode != HttpStatusCode.OK)
  8. return;
  9. Stream resStream = response.GetResponseStream();
  10. this.pictureBox1.Image = new Bitmap(resStream);
读取页面返回的字符串,并显示在Lable上 view plaincopy to clipboardprint?
  1. HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://10.225.105.18/pic/Default2.aspx");
  2. request.Timeout = 20000;
  3. request.ServicePoint.ConnectionLimit = 100;
  4. request.ReadWriteTimeout = 30000;
  5. request.Method = "GET";
  6. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  7. if (response.StatusCode != HttpStatusCode.OK)
  8. return;
  9. StreamReader reader = new StreamReader(response.GetResponseStream());
  10. this.label1.Text = reader.ReadLine();
注:http://127.0.0.1/pic/default.aspx 为你要访问的生成图片注册码的页面