Roger
27 de febrero de 2015, 17:56
Amigos de foro
Necesito incrustar en mi programa un enlace de consuta pero esta tiene un capcha y revisando la red un programa que evita este capcha pero esta echo en visual basic y utiliza
tessnet2.dll para convertir la imagen de pantalla en texto de esa forma lee el capcha y lo pone en el link y ya esta la consulta en linea con los datos.
aca las codigos private void mt_otro3()
{
try
{
//Creating the Web Request.
HttpWebRequest httpWebRequest = HttpWebRequest.Create("http://www.sunat.gob.pe/cl-ti-itmrconsruc/jcrS00Alias") as HttpWebRequest;
//Specifing the Method
httpWebRequest.Method = "POST";
//Data to Post to the Page, itis key value pairs; separated by "&"
string data = "accion=consPorRuc&nroRuc=20100495989&search1:20100495989&codigo=FGRT&tipdoc=1";
//Setting the content type, it is required, otherwise it will not work.
httpWebRequest.ContentType = "application/x-www-form-urlencoded";
//Getting the request stream and writing the post data
using (StreamWriter sw = new StreamWriter(httpWebRequest.GetRequestStream()))
{
sw.Write(data);
}
//Getting the Respose and reading the result.
HttpWebResponse httpWebResponse = httpWebRequest.GetResponse() as HttpWebResponse;
using (StreamReader sr = new StreamReader(httpWebResponse.GetResponseStream()))
{
MessageBox.Show(sr.ReadToEnd());
}
}
catch (WebException wex)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("ERROR:" + wex.Message + ". STATUS: " + wex.Status.ToString());
if (wex.Status == WebExceptionStatus.ProtocolError)
{
var response = ((HttpWebResponse)wex.Response);
sb.AppendLine(string.Format("Status Code : {0}", response.StatusCode));
sb.AppendLine(string.Format("Status Description : {0}", response.StatusDescription));
try
{
StreamReader reader = new StreamReader(response.GetResponseStream());
sb.AppendLine(reader.ReadToEnd());
}
catch (WebException ex) { throw; }
}
throw new Exception(sb.ToString(), wex);
}
}
inclusive he descargado un .exe no se en que lenguaje pero funciona de esa manera
yo creo que con un poco de paciencia se puede hacer en powercobol
Necesito incrustar en mi programa un enlace de consuta pero esta tiene un capcha y revisando la red un programa que evita este capcha pero esta echo en visual basic y utiliza
tessnet2.dll para convertir la imagen de pantalla en texto de esa forma lee el capcha y lo pone en el link y ya esta la consulta en linea con los datos.
aca las codigos private void mt_otro3()
{
try
{
//Creating the Web Request.
HttpWebRequest httpWebRequest = HttpWebRequest.Create("http://www.sunat.gob.pe/cl-ti-itmrconsruc/jcrS00Alias") as HttpWebRequest;
//Specifing the Method
httpWebRequest.Method = "POST";
//Data to Post to the Page, itis key value pairs; separated by "&"
string data = "accion=consPorRuc&nroRuc=20100495989&search1:20100495989&codigo=FGRT&tipdoc=1";
//Setting the content type, it is required, otherwise it will not work.
httpWebRequest.ContentType = "application/x-www-form-urlencoded";
//Getting the request stream and writing the post data
using (StreamWriter sw = new StreamWriter(httpWebRequest.GetRequestStream()))
{
sw.Write(data);
}
//Getting the Respose and reading the result.
HttpWebResponse httpWebResponse = httpWebRequest.GetResponse() as HttpWebResponse;
using (StreamReader sr = new StreamReader(httpWebResponse.GetResponseStream()))
{
MessageBox.Show(sr.ReadToEnd());
}
}
catch (WebException wex)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("ERROR:" + wex.Message + ". STATUS: " + wex.Status.ToString());
if (wex.Status == WebExceptionStatus.ProtocolError)
{
var response = ((HttpWebResponse)wex.Response);
sb.AppendLine(string.Format("Status Code : {0}", response.StatusCode));
sb.AppendLine(string.Format("Status Description : {0}", response.StatusDescription));
try
{
StreamReader reader = new StreamReader(response.GetResponseStream());
sb.AppendLine(reader.ReadToEnd());
}
catch (WebException ex) { throw; }
}
throw new Exception(sb.ToString(), wex);
}
}
inclusive he descargado un .exe no se en que lenguaje pero funciona de esa manera
yo creo que con un poco de paciencia se puede hacer en powercobol