【转】C# 获取网页验证码

C#获取网页的验证码,并且显示在 picbox控件上

  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上

  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 为你要访问的生成图片注册码的页面

转载于:https://www.cnblogs.com/alexzp/p/3236616.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值