Exemple #1
0
        public async Task Execute(ICrawlingContext context)
        {
            var doc = await CrawlingHelper.GetHtmlDocument(context.Client, Url);

            CrawlingHelper.SetEventParams(context, doc);

            var hidStepGuid = doc.GetElementbyId("hidStepGuid")?.GetAttributeValue("value", null);

            context.Set("hidStepGuid", hidStepGuid);

            var response = await context.Client.PostAsync(Url, new FormUrlEncodedContent(BuildFormData(context)));

            string redirectFile = null;

            try
            {
                redirectFile = response.Headers.Location?.Segments.LastOrDefault();
            }
            catch (Exception)
            {
                //ignore
            }

            EnsureRedirectFile(redirectFile);
        }
Exemple #2
0
 public static void SetEventParams(ICrawlingContext context, HtmlDocument document)
 {
     context.Set("viewState", document.GetElementbyId("__VIEWSTATE")?.GetAttributeValue("value", null));
     context.Set("eventValidation", document.GetElementbyId("__EVENTVALIDATION")?.GetAttributeValue("value", null));
 }