Tópico anterior Próximo tópico Novo tópico
C#
#495377 - 10/10/2020 10:59:30 | ||||
![]() FABRICIOWEB BELO HORIZONTE Cadast. em:Novembro/2011 ![]() |
Anexos estao visíveis somente para usuários registrados Olá pessoal hoje eu trago aqui para vcs um site muito mas muito barato de uma api de ocr captcha que vai ser muito util para vcs ae nos trabalhos de cnpj buscando ae direto da receita eu ja publiquei aqui como obter os dados na receita com o c# o codigo esta na area de upload hoje vou mostrar como ler automaticamente uma captchaprimeira coisa a fazer criar uma conta nesse site https://azcaptcha.com/ string key = 'SUA KEY DO SITE'; public static String gethtmlform(string Url) //htmlform { HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(Url); myRequest.Method = 'GET'; WebResponse myResponse = myRequest.GetResponse(); StreamReader sr = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8); string result = sr.ReadToEnd(); sr.Close(); myResponse.Close(); return result; } public string captcharesult() //captcharesult { //POST try { System.Net.ServicePointManager.Expect100Continue = false; var request = (HttpWebRequest)WebRequest.Create('http://azcaptcha.com/in.php'); string base64String1 = ''; using (Image image = Image.FromFile(@'C:/SUA_IMAGEM_DA_CAPTCHA.JPG')) { using (MemoryStream m = new MemoryStream()) { image.Save(m, image.RawFormat); byte[] imageBytes = m.ToArray(); // Convert byte[] to Base64 String base64String1 = Convert.ToBase64String(imageBytes); } } string base64string = base64String1; //Convert.ToBase64String(GetCaptchaImage()); var postData = 'method=base64&key=' + key + '&body=' + WebUtility.UrlEncode(base64string); var data = Encoding.ASCII.GetBytes(postData); request.Method = 'POST'; request.ContentType = 'application/x-www-form-urlencoded'; request.ContentLength = data.Length; using (var stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); } var response = (HttpWebResponse)request.GetResponse(); string responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); if (responseString.Contains('OK|')) { // GET string captcha = ''; while (true) { captcha = gethtmlform('http://azcaptcha.com/res.php?key=' + key + '&action=get&id=' + responseString.Split('|')[1]); if (captcha == 'CAPCHA_NOT_READY') { System.Threading.Thread.Sleep(5000); continue; } if (captcha == '_') { System.Threading.Thread.Sleep(5000); continue; } if (captcha.Contains('OK|')) { captcha = captcha.Replace('OK|', ''); } txtLetras.Text=(captcha); // PARA ONDE VAI RETORNAR return captcha; } } return ''; } catch (Exception e) { string tt = e.Message; return tt; } } PARA CHAMAR O EVENTO captcharesult(); |
|||
#495378 - 10/10/2020 11:02:28 | ||||
![]() FABRICIOWEB BELO HORIZONTE Cadast. em:Novembro/2011 ![]() |
Anexos estao visíveis somente para usuários registrados valores |
|||
Tópico anterior Próximo tópico Novo tópico