AmazonScrape.Scraper.CreateHttpRequest C# (CSharp) Method

CreateHttpRequest() public static method

Given a URL, loads and returns a string representing a web page's markup
public static CreateHttpRequest ( Uri URL ) : String
URL System.Uri
return String
        public static String CreateHttpRequest(Uri URL)
        {
            WebRequest request = HttpWebRequest.Create(URL);
            request.Method = "GET";

            String html = "";
            try
            {
                using (StreamReader reader = new StreamReader(request.GetResponse().GetResponseStream()))
                {
                    html = reader.ReadToEnd();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Unable to load page " + URL.ToString() + ". Check your internet connection.");
            }
            return html;
        }

Usage Example

Example #1
0
        /// <summary>
        /// Uses an additional page load to determine Prime eligibility
        /// with accuracy
        /// </summary>
        /// <param name="productURL"></param>
        /// <returns></returns>
        public static bool GetStrictPrimeEligibility(Uri productURL)
        {
            string html = Scraper.CreateHttpRequest(productURL);

            // Non-prime eligible results call this function with a "0" first
            // parameter; here we look specifically for "1", which
            // denotes prime eligibility
            string primeEligiblePattern = @"bbopJS.initialize\(1,";

            string match = GetSingleRegExMatch(html, primeEligiblePattern);

            return(match.Length > 0);
        }
All Usage Examples Of AmazonScrape.Scraper::CreateHttpRequest