public async Task <bool> DeleteFromRevolico(FormDeleteAnuncio formDeleteAnuncio) { string Url; try { for (int i = 0; i < 6; i++) { string jsonForm = $"[{JsonConvert.SerializeObject(formDeleteAnuncio)}]"; string answer = await Requests.PostAsync(Requests.apiRevolico, jsonForm); if (answer.Contains("\"status\":200") || answer.Contains("\"errors\":null") || answer.Contains("DeleteAdWithoutUserMutationPayload")) { return(true); } await Task.Delay(TimeSpan.FromSeconds(20)); } } catch (Exception) { Url = $"{Requests.RevolicoModifyUrl}?key={formDeleteAnuncio.variables.token}{formDeleteAnuncio.variables.id}"; throw new Exception("Error Removing from Revolico " + Url); } Url = $"{Requests.RevolicoModifyUrl}?key={formDeleteAnuncio.variables.token}{formDeleteAnuncio.variables.id}"; throw new Exception("Error Removing from Revolico " + Url); }
public async Task <bool> DeleteFromRevolico(string url) { string htmlAnuncio = await Requests.GetAsync(url); FormUpdateAnuncio formAnuncio = ParseFormAnuncio(htmlAnuncio); FormDeleteAnuncio formDeleteAnuncio = new FormDeleteAnuncio(formAnuncio); return(await DeleteFromRevolico(formDeleteAnuncio)); }
public async Task <ReinsertResult> ReInsert(Anuncio anuncio, string Key2Captcha, string email) { ReinsertResult result; CaptchaAnswer captchaResponse; FormInsertAnuncio formInsertAnuncio; FormDeleteAnuncio formDeleteAnuncio; try { // Get Anuncio string htmlAnuncio = await Requests.GetAsync(anuncio.Url); GetException(htmlAnuncio, anuncio.Url, false); // Parse All Data FormUpdateAnuncio formAnuncio = ParseFormAnuncio(htmlAnuncio); formAnuncio.variables.email = email; anuncio.FormUpdateAnuncio = JsonConvert.SerializeObject(formAnuncio); //Solve Captcha captchaResponse = await ResolveCaptcha(Key2Captcha, Requests.RevolicoInserrUrl, htmlAnuncio); formAnuncio.variables.captchaResponse = captchaResponse.Answerv2; //formAnuncio.variables.botScore = captchaResponse.Answerv3; // Parse Insert and Delete Forms formInsertAnuncio = new FormInsertAnuncio(formAnuncio); formDeleteAnuncio = new FormDeleteAnuncio(formAnuncio); // Insert new Announce string answer = await InsertAnuncio(formInsertAnuncio); // Verify Insertion GetException(answer, anuncio.Url, true, captchaResponse); // Update new Anuncio URL InsertResult insertResult = ParseInsertResult(answer); anuncio.Url = $"{Requests.RevolicoModifyUrl}?key={insertResult.FullId}"; _log.LogWarning($"ReplaceInsert {anuncio.Id} {insertResult.FullId}"); // Delete from Revolico await DeleteFromRevolico(formDeleteAnuncio); result = new ReinsertResult(anuncio); } catch (Exception ex) { result = new ReinsertResult(anuncio, ex); } return(result); }