0% found this document useful (0 votes)
12 views3 pages

Scrapping API

Uploaded by

umar fayyaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Scrapping API

Uploaded by

umar fayyaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

app.

MapPost("/GetUserData", [Authorize] async (HttpContext httpContext) =>


{
try
{

var requestModel = await


httpContext.Request.ReadFromJsonAsync<RequestModel>();

TwoCaptcha.TwoCaptcha solver = new


TwoCaptcha.TwoCaptcha("f7acd2109c8abb9eaaf60d76de8412f3");

ReCaptcha captcha = new ReCaptcha();


captcha.SetSiteKey("6Lfj6nIUAAAAAD76VheUIK0jYhKYxJRdQF8eG7lh");
captcha.SetUrl("https://smartservices.icp.gov.ae/echannels/web/client/
guest/index.html#/leavePermit/588/step1?
administrativeRegionId=1&withException=false");
captcha.SetVersion("v2");
captcha.SetAction("verify");
captcha.SetScore(0.3);

try
{

solver.Solve(captcha).Wait();

if (!string.IsNullOrEmpty(captcha.Code))
{

var client = new HttpClient();


client.DefaultRequestHeaders.Add("Accept",
"application/json, text/plain, */*");
client.DefaultRequestHeaders.Add("Accept-Language", "en-
US,en;q=0.9");
client.DefaultRequestHeaders.Add("Referer",
"https://beta.smartservices.icp.gov.ae/echannels/web/client/guest/index.html");
client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0
(Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/133.0.0.0 Safari/537.36");
client.DefaultRequestHeaders.Add("languageId", "2");

var response =
client.GetAsync("https://beta.smartservices.icp.gov.ae/echannels/api/api/user/
guest/login").Result;
var json = response.Content.ReadAsStringAsync().Result;
var jsonObject = JObject.Parse(json);

client.DefaultRequestHeaders.Add("userToken",
jsonObject["userToken"]?.ToString());
client.DefaultRequestHeaders.Add("refreshToken",
jsonObject["refreshToken"]?.ToString());
client.DefaultRequestHeaders.Add("CURRENT_PORTAL", "ICA");
//client.DefaultRequestHeaders.Add("Content-Type",
"application/json;charset=utf-8");
var country = CountryList.Get().Where(x =>
x.CountryName==requestModel.Country.ToUpper()).FirstOrDefault();
int coId = 0;
if(country !=null)
{
coId=country.CountryID;
}
var requestData = new
{
request = new
{
identificationType = 1,
fileModuleId = 2,
personUnifiedNumber =
requestModel.UnifiedNumber,
currentNationalityId = coId,//
requestModel.Country,
dateOfBirth = requestModel.DOB,
applicantMobile = "00971555555555",
applicantEmail = "[email protected]",
recaptchaResponse =
captcha.Code //"03AFcWeA4RnHKiGhqOJsCgnZ8sSfPebqO6dQPhNpKgX7A_7oMa3bnvDC5uN5BjGZM6
GFHIy9qr6pRwEcJ3z1F5dyzIdJ2mUch8H20CLVOVn-bpWVrnTtcL0j5pmfCD42NpPjNQz8HK9sMBEkAvqq-
EwI32hL9HYv1FOMn8rHfy92IkgjOMP0_unONRMy43ecjRpzt2H7EJUBB1LryM1shrd-
qk0jHf7gs5Xuj4gfCibnQ8MvUIYpbAYsioab0qnvI5PWdD9bFilOltWUIhULIzYuOhouREcIUEO-CR-
IbzheCsjfbkhDEdXs6W1K6DfANJxgUlCmdrK-
DSZZAVdHlQsXS9GMy_e0jO52cVR44h1r7ftWyM6ls2r5HC2t4X819PUEJDilalW7WxpswhwWoZvkeMb2NhS
t2jamJQWIEcIg-PnQN0yUPEWEmO4uBDuh9YpZw9lHzYTRUm0Cd6af3gQM-
GgKBRljTNwgBUNYCZC4tHupfSju1fQtXEfX-
2KpzkHuCIWAW0bRG_MXn3cJ50bCCCLu3fMDj9MLh1FzxaPbzTkgNNGpQ5d_pN-
dY5rUlcs1BQ6FUCDcfnE2mPqN1pWSk7mKIN3skG8WTtw_29wdxsEJrycc-ugBOi9XBo40hytl6U-K-
sVo4K_yyYi-b8xeun3pT67hPa7bYTuUqVdHF7hsbQAdOYEeJrxY6eEbELnkr8PpoXHqeZzU-
q3MbooQalm_zuOa6meydKSh94xj7mTmrOjQa-
mYFj1vP3eFM1L8eUMfBHY9Uua22U40MjofhnnbIL6PHadI3zb5P2fM92YvoslKwE5oPJRkzRlvQwiM4LexX
zC8CKwN7D0uIjfId0H4VnlMe3s8gvEXWIQ8q8rzTsBREr9q58-
Z0W__f5FM8VFyDLF1Kb0PczgUTvht0TGnEnC7_lSky2nanQt8K5-mQmZp9pEH1k2-
5A3cx6hj7PAkSfsBel-6YhDBjRtc8sd1eI8Efz2A"
},
serviceTransactionId = "588",
administrativeRegionId = "1",
withException = false,
currentStep = "leavePermitRequest.step2"
};

var jsonContent = new


StringContent(JsonSerializer.Serialize(requestData), Encoding.UTF8,
"application/json");

var response2 = await


client.PostAsync("https://smartservices.icp.gov.ae/echannels/api/api/leavePermit/
draft/add", jsonContent);

var json2 = response2.Content.ReadAsStringAsync().Result;

var leavePermitRequest =
JsonSerializer.Deserialize<LeavePermitRequest>(json2, new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
});
return leavePermitRequest.Request;
//var response2 =
client.GetAsync($"https://beta.smartservices.icp.gov.ae/echannels/api/api/
leavePermit/checkValidateLeavePermitRequest?
departmentCode=&identityNumber={identity}&moduleId=2&passportNationalityId=&passpor
tNumber=&sequenceNumber=&serviceCode=&serviceYear=&unifiedNumber=").Result;

Console.WriteLine("Captcha solved: " + captcha.Code);


}
catch (AggregateException e)
{
throw new Exception("Something went wrong...");

// Console.WriteLine("Error occurred: " +


e.InnerExceptions.First().Message);
}

// return json2;
}
catch (Exception ex)
{
throw new Exception("Something went wrong...");

}
return null;
});

You might also like