public BitMap GetCaptcha() { string htmlResult; using (var wc = new CookieAwareWebClient()) { wc.SetCookieContainer(_cookies); wc.Headers[HttpRequestHeader.UserAgent] = "Mozilla/4.0 (compatible; Synapse)"; wc.Headers[HttpRequestHeader.KeepAlive] = "300"; htmlResult = wc.DownloadString(urlBaseReceitaFederal + paginaPrincipal); } if (htmlResult.Length > 0) { var wc2 = new CookieAwareWebClient(); wc2.SetCookieContainer(_cookies); wc2.Headers[HttpRequestHeader.UserAgent] = "Mozilla/4.0 (compatible; Synapse)"; wc.Headers[HttpRequestHeader.KeepAlive] = "300"; byte[] data = wc2.DownloadData(urlBaseReceitaFederal + paginaCaptcha); return(new BitMap(new MemoryStream(data))); } return(null); }