Exemple #1
0
        private IEnumerable <KeyValuePair <string, string> > BuildFormData(ICrawlingContext context)
        {
            return(new[]
            {
                new KeyValuePair <string, string>("__EVENTTARGET", ""),
                new KeyValuePair <string, string>("__EVENTARGUMENT", ""),
                new KeyValuePair <string, string>("__VIEWSTATEGENERATOR", "A42C1B88"),
                new KeyValuePair <string, string>("__VIEWSTATE", context.Get <string>("viewState")),
                new KeyValuePair <string, string>("__EVENTVALIDATION", context.Get <string>("eventValidation")),

                new KeyValuePair <string, string>("receiptName", Nesach.Name ?? ConfigurationManager.AppSettings["name"]),
                new KeyValuePair <string, string>("receiptEmail", Nesach.Email ?? ConfigurationManager.AppSettings["email"]),
                new KeyValuePair <string, string>("cardNumberTextBox", ConfigurationManager.AppSettings["cardNumber"]),
                new KeyValuePair <string, string>("yearDropDown", ConfigurationManager.AppSettings["expirationYear"]),
                new KeyValuePair <string, string>("monthDropDown", ConfigurationManager.AppSettings["expirationMonth"]),
                new KeyValuePair <string, string>("IdNumberTextBox", ConfigurationManager.AppSettings["idNumber"]),

                new KeyValuePair <string, string>("hidStepGuid", context.Get <string>("hidStepGuid")),
                new KeyValuePair <string, string>("chkBoxEula", "on"),
                new KeyValuePair <string, string>("rbCardType", "on"),
                new KeyValuePair <string, string>("rbReceipientType", "on"),

                new KeyValuePair <string, string>("payerPhone", ""),
                new KeyValuePair <string, string>("inputAutomaticCC", ""),
                new KeyValuePair <string, string>("CvvNumberTextBox", ""),
                new KeyValuePair <string, string>("CardOwnerNameTextbox", ""),
                new KeyValuePair <string, string>("creditTextBox", ""),
                new KeyValuePair <string, string>("sapakTextBox", ""),
                new KeyValuePair <string, string>("paymentTypeTextBox", ""),
                new KeyValuePair <string, string>("payImg2.x", "681"),
                new KeyValuePair <string, string>("payImg2.y", "430"),
            });
        }
Exemple #2
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 #3
0
        public async Task Execute(ICrawlingContext context)
        {
            context.Client.BaseAddress            = new Uri("https://ecom.gov.il");
            context.HttpHandler.AllowAutoRedirect = false;

            var response = await context.Client.GetAsync(Url);

            var html = await response.Content.ReadAsStringAsync();

            var doc = new HtmlDocument();

            doc.LoadHtml(html);

            CrawlingHelper.SetEventParams(context, doc);
        }
Exemple #4
0
        public async Task Execute(ICrawlingContext context)
        {
            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 #5
0
 private IEnumerable <KeyValuePair <string, string> > BuildFormData(ICrawlingContext context)
 {
     return(new[]
     {
         new KeyValuePair <string, string>("__EVENTTARGET", "m_lbAcceptBtn"),
         new KeyValuePair <string, string>("__EVENTARGUMENT", ""),
         new KeyValuePair <string, string>("__VIEWSTATEGENERATOR", "97D0459B"),
         new KeyValuePair <string, string>("m_ddlNesachTypeBooks", "F"),
         new KeyValuePair <string, string>("m_ddlNameBook", "1013"),
         new KeyValuePair <string, string>("auth", "G"), // Search by Gush/Helka (G) or book (F)
         new KeyValuePair <string, string>("rowInputText_rowBookNum_0_0", "111111111"),
         new KeyValuePair <string, string>("rowInputText_rowPageNum_0_0", "11111"),
         new KeyValuePair <string, string>("m_ddlNesachType", Nesach.Type.ToString()),
         new KeyValuePair <string, string>("rowInputText_rowGush_0_0", Nesach.Gush),
         new KeyValuePair <string, string>("rowInputText_rowHelka_0_0", Nesach.Helka),
         new KeyValuePair <string, string>("rowInputText_rowTatHelka_0_0", Nesach.SubHelka),
         new KeyValuePair <string, string>("__VIEWSTATE", context.Get <string>("viewState")),
         new KeyValuePair <string, string>("__EVENTVALIDATION", context.Get <string>("eventValidation")),
     });
 }
Exemple #6
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));
 }