protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         Stream stream = ClassHttpPost.GetHttpPageSteam("http://www.ofcard.com/image.jsp?", "gb2312", "get", "", "", "", "*/*", "");
         if (stream == null)
         {
             return;
         }
         List <byte> list = new List <byte>();
         while (true)
         {
             int data = stream.ReadByte();
             if (data == -1)
             {
                 break;
             }
             list.Add((byte)data);
         }
         byte[] bytes = list.ToArray();
         Response.Clear();
         Response.BinaryWrite(bytes);
     }
     catch (System.Exception ex)
     {
     }
 }
示例#2
0
        public bool GetImage(string strUrl, string strFile, out string strError, out string strMemo, out string strTargeID)
        {
            strError   = "";
            strMemo    = "";
            strTargeID = "";
            try
            {
                strUrl = string.Format("http://captcha.pconline.com.cn/captcha/v.jpg?{0}", DateTime.Now.ToString("yyyyMMddHHmmss"));
                Stream stream = m_webPost.GetHttpPageSteam(strUrl, "gb2312", "get", "", "", "http://m.pconline.com.cn/szwxnet/messages_all.html", "*/*", "");
                if (stream == null)
                {
                    strError = "获取验证码失败,网络错误";
                    return(false);
                }

                List <byte> list = new List <byte>();
                while (true)
                {
                    int data = stream.ReadByte();
                    if (data == -1)
                    {
                        break;
                    }
                    list.Add((byte)data);
                }
                byte[] bytes = list.ToArray();
                if (File.Exists(strFile))
                {
                    File.Delete(strFile);
                }
                FileStream   fs = new FileStream(strFile, FileMode.Create);
                BinaryWriter bw = new BinaryWriter(fs);
                bw.Write(bytes);
                bw.Close();
                fs.Close();
                return(true);
            }
            catch
            {
                strError = "获取验证码失败,获取异常";
                return(false);
            }
        }
示例#3
0
        public bool GetImage(string strFile, out string strError)
        {
            strError = "";
            try
            {
                string strUrl = string.Format("http://mydealer.zol.com.cn/admin/include/key.php?type=1&mixture={0}", DateTime.Now.ToString("yyyyMMddHHmmss"));
                Stream stream = m_webPost.GetHttpPageSteam(strUrl, "gb2312", "get", "", "", "http://dealer.zol.com.cn/merchant_login.php", "*/*", "");
                if (stream == null)
                {
                    strError = "获取验证码失败,网络错误";
                    return(false);
                }

                List <byte> list = new List <byte>();
                while (true)
                {
                    int data = stream.ReadByte();
                    if (data == -1)
                    {
                        break;
                    }
                    list.Add((byte)data);
                }
                byte[] bytes = list.ToArray();
                if (File.Exists(strFile))
                {
                    File.Delete(strFile);
                }
                FileStream   fs = new FileStream(strFile, FileMode.Create);
                BinaryWriter bw = new BinaryWriter(fs);
                bw.Write(bytes);
                bw.Close();
                fs.Close();
                return(true);
            }
            catch
            {
                strError = "获取验证码失败,获取异常";
                return(false);
            }
        }
示例#4
0
        private void button2_Click(object sender, EventArgs e)
        {
            Stream stream = ClassHttpPost.GetHttpPageSteam("http://www.ofcard.com/image.jsp?", "gb2312", "get", "", "", "", "*/*", "");

            List <byte> list = new List <byte>();

            while (true)
            {
                int data = stream.ReadByte();
                if (data == -1)
                {
                    break;
                }
                list.Add((byte)data);
            }
            File.WriteAllBytes("c:\\2.bmp", list.ToArray());
        }
示例#5
0
        public bool GetCheckCode()
        {
            try
            {
                Stream stream = ClassHttpPost.GetHttpPageSteam("http://www.ofcard.com/image.jsp?", "gb2312", "get", "", "", "", "*/*", "");

                List <byte> list = new List <byte>();
                while (true)
                {
                    int data = stream.ReadByte();
                    if (data == -1)
                    {
                        break;
                    }
                    list.Add((byte)data);
                }
                File.WriteAllBytes("c:\\2.bmp", list.ToArray());
                return(true);
            }
            catch (System.Exception ex)
            {
            }
            return(false);
        }