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