-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
Buscar en el string postData y cambiar por los valores correspondientes:
public bool IsNCFValid(string rnc, string ncf)
{
HttpWebRequest webrequest =
(HttpWebRequest)WebRequest.Create("https://dgii.gov.do/app/WebApps/ConsultasWeb/consultas/ncf.aspx");
webrequest.Method = "POST";
webrequest.ContentType = "application/x-www-form-urlencoded; charset=utf-8";
webrequest.Headers.Add("Origin", "https://dgii.gov.do");
webrequest.Referer = "https://dgii.gov.do/app/WebApps/ConsultasWeb/consultas/ncf.aspx";
webrequest.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134";
webrequest.Headers.Add("X-MicrosoftAjax", "Delta=true");
webrequest.Headers.Add("Cache-Control", "no-cache");
webrequest.Accept = "*/*";
webrequest.Headers.Add("Accept-Language", "en-US,en;q=0.8,es-US;q=0.5,es;q=0.3");
webrequest.Headers.Add("Accept-Encoding", "gzip, deflate, br");
webrequest.KeepAlive = true;
webrequest.Headers.Add("Cookie", "NSC_EHJJ_efgbvmu_mcwt=ffffffffc3a0e53e45525d5f4f58455e445a4a423660; _ga=GA1.3.1057587116.1543410096; _gid=GA1.3.2007075897.1544454483; NSC_EHJJ_TTM_BQQ_MCWT=ffffffffc3a0e52245525d5f4f58455e445a4a42378b");
webrequest.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
string postData = $"ctl00%24smMain=ctl00%24upMainMaster%7Cctl00%24cphMain%24btnConsultar&__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUJNTM1NDc0MDQ5ZGRCFUYoDcVRgzEntcKfSuvPnC2VhA%3D%3D&__EVENTVALIDATION=%2FwEWBAKh8pDuCgK%2B9LSUBQLfnOXIDAKErv7SBhjZB34%2F%2FpbvvJzrbkFCGGPRElcd&ctl00%24cphMain%24txtRNC={rnc}&ctl00%24cphMain%24txtNCF={ncf}&__ASYNCPOST=true&ctl00%24cphMain%24btnConsultar=Consultar";
UTF8Encoding encoding = new UTF8Encoding();
byte[] data = encoding.GetBytes(postData.ToString());
// Set the content length of the string being posted.
webrequest.ContentLength = data.Length;
System.IO.Stream newStream = webrequest.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
HttpWebResponse response = (HttpWebResponse)webrequest.GetResponse();
using (System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream(), encoding))
{
string responseText = reader.ReadToEnd();
Console.WriteLine(responseText);
return responseText.Contains(" válido");
}
}Metadata
Metadata
Assignees
Labels
No labels