Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.AsyncMode = true;
            if (Page.IsPostBack)
            {
                try
                {
                    if (txtAddress.Value != null && txtAddress.Value.Trim() != "")
                    {
                        //Validate URL
                        var url = txtAddress.Value.ToLower().Trim();
                        if (!url.StartsWith("http://") && !url.StartsWith("https://"))
                        {
                            url = "http://" + url;
                        }
                        string Pattern = @"^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$";
                        Regex  Rgx     = new Regex(Pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
                        if (Rgx.IsMatch(url))
                        {
                            Session["webScraperData"] = null;
                            var screenshotResponse = APICall.call(APICall.API_WebScraper, url);
                            if (screenshotResponse != null)
                            {
                                if (screenshotResponse.Length > 5000)
                                {
                                    screenshotResponse = screenshotResponse.Substring(0, 5000);
                                }
                                Session["webScraperData"] = screenshotResponse;
                                Response.Redirect("webscraper?capture=" + Guid.NewGuid().ToString().ToLower());
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            if (Session["webScraperData"] == null)
            {
                //Load sample graph data
                string sampleFilePathpath = Server.MapPath("/samples/sampleWebScrape.txt");
                using (var sr = new StreamReader(sampleFilePathpath))
                {
                    var content = sr.ReadToEnd();
                    txtData.Value = content;
                }
            }
            else
            {
                txtData.Value = Session["webScraperData"].ToString();
            }
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.AsyncMode = true;
            if (Page.IsPostBack)
            {
                try
                {
                    if (txtAddress.Value != null && txtAddress.Value.Trim() != "")
                    {
                        //Validate URL
                        var url = txtAddress.Value.ToLower().Trim();
                        if (!url.StartsWith("http://") && !url.StartsWith("https://"))
                        {
                            url = "http://" + url;
                        }
                        string Pattern = @"^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$";
                        Regex  Rgx     = new Regex(Pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
                        if (Rgx.IsMatch(url))
                        {
                            Session["webPDFData"] = null;

                            //Get Screenshot
                            var screenshotResponse = APICall.call(APICall.API_PDF, url);
                            if (screenshotResponse != null)
                            {
                                var returnedData = JsonConvert.DeserializeObject <Dictionary <string, object> >(screenshotResponse);
                                Session["webPDFData"] = returnedData["data"];
                                var fileName = Session["webPDFData"].ToString().Split('/').Last();
                                Response.Redirect("webpdf?capture=" + fileName);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            if (Session["webPDFData"] == null)
            {
                screenshotImage.Src = "samples/samplePDF.pdf";
            }
            else
            {
                screenshotImage.Src = Session["webPDFData"].ToString();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            this.AsyncMode = true;
            if (Page.IsPostBack)
            {
                try
                {
                    if (txtAddress.Value != null && txtAddress.Value.Trim() != "")
                    {
                        //Validate URL
                        var url = txtAddress.Value.ToLower().Trim();
                        //if (!url.StartsWith("http://") && !url.StartsWith("https://"))
                        //    url = "http://" + url;
                        string Pattern = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
                        Regex  Rgx     = new Regex(Pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
                        if (Rgx.IsMatch(url) && !url.EndsWith("."))
                        {
                            Session["emailValidateData"] = null;
                            var screenshotResponse = APICall.call(APICall.API_EmailValidator, url);
                            if (screenshotResponse != null)
                            {
                                Session["emailValidateData"] = screenshotResponse;
                                Response.Redirect("emailvalidate?email=" + Guid.NewGuid().ToString().ToLower());
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            if (Session["emailValidateData"] == null)
            {
                //Load sample graph data
                string sampleFilePathpath = Server.MapPath("/samples/sampleEmailValidate.txt");
                using (var sr = new StreamReader(sampleFilePathpath))
                {
                    var content = sr.ReadToEnd();
                    txtData.Value = content;
                }
            }
            else
            {
                txtData.Value = Session["emailValidateData"].ToString();
            }
        }