日期:2014-05-17  浏览次数:20774 次

急找高手求解决,C#获取网页上的验证码显示到pictureBox上
本人想获取这个网站上的验证码显示在我的pictureBox控件上, http://www.scjj.gov.cn:8635有能解决的请把代码发到我的邮箱jhjking@yeah.net里面,谢谢~~谢谢~
------最佳解决方案--------------------


        public static Stream GetStream(string url, CookieContainer cookieContainer)
        {
            HttpWebRequest httpWebRequest = null;
            HttpWebResponse httpWebResponse = null;

            try
            {
                httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url);
                httpWebRequest.CookieContainer = cookieContainer;
                httpWebRequest.ContentType = contentType;
                httpWebRequest.Referer = referer;
                httpWebRequest.Accept = accept;
                httpWebRequest.UserAgent = userAgent;
                httpWebRequest.Method = "GET";
                httpWebRequest.ServicePoint.ConnectionLimit = int.MaxValue;

                httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                Stream responseStream = httpWebResponse.GetResponseStream();

                return responseStream;
            }
            catch (Exception)
            {
                return null;
            }
        }

上楼敲错了。
------其他解决方案--------------------
你看看img的连接,直接用webclient就可以下载
------其他解决方案--------------------
我都试过了~还就是不行呢~
------其他解决方案--------------------
引用:
你看看img的连接,直接用webclient就可以下载


要注意,一般来说,每次获取验证码会导致服务器端产生一个新的,这样验证码是可以获得,但是失去了意义。你可以从浏览器的缓存文件夹中抓取。
------其他解决方案--------------------
1.得到image的路径(路径中可能有一些可变的参数,还有cookie必须带上)
2.下载,或直接以流的形式获取然后转换成图片
3.....
------其他解决方案--------------------
引用: