示例#1
0
        public void GetCategoriesTest()
        {
            AmazonParser parser = new AmazonParser(@"http://www.amazon.com/Best-Sellers-Books-Investing/zgbs/books/2665");

            string[] expecteds = new string[] {
                "Analysis & Strategy",
                "Bonds",
                "Commodities",
                "Futures",
                "Introduction",
                "Mutual Funds",
                "Online Trading",
                "Options",
                "Real Estate",
                "Stocks"
            };
            int i = 0;

            foreach (KeyValuePair <string, string> pair in parser.GetCategories())
            {
                System.Diagnostics.Debug.WriteLine("{0}:{1}", pair.Key, pair.Value);
                Assert.AreEqual(expecteds[i], pair.Key);
                i++;
            }
        }
示例#2
0
        public void ParseTest()
        {
            AmazonParser parser = new AmazonParser(@"http://www.amazon.com/Best-Sellers-Books-Investing/zgbs/books/2665");

            parser.Parse();
            System.Diagnostics.Debug.WriteLine("Result found: " + parser.Result.Count());
        }
示例#3
0
        public void ParseToAffiliate()
        {
            Configuration config  = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            string        baseUrl = config.AppSettings.Settings["AmazonBaseUrl"].Value;
            string        url     = config.AppSettings.Settings["Amazonaire"].Value;

            AmazonParser parser = new AmazonParser(baseUrl);

            parser.Parse();
            parser.ListAffiliate(url);

            System.Diagnostics.Debug.WriteLine("Result found: " + parser.Result.Count());
        }
示例#4
0
        public void Scraper_GetPageContent()
        {
            // Arrange
            AmazonParser parser = AmazonModule.Create <AmazonParser>();

            // Act
            var page = parser.ParseAsinPage(GetStringRessource(this.GetType().Assembly, "B082XY23D5.html"));

            // Assert
            Assert.NotNull(page);

            // dummy
            Assert.Equal("Samsung Galaxy S20 5G Factory Unlocked New Android Cell Phone US Version, 128GB of Storage, Fingerprint ID and Facial Recognition, Long-Lasting Battery, Cosmic Gray", page.ProductTitle);
            Assert.Equal("/Samsung-Unlocked-Fingerprint-Recognition-Long-Lasting/product-reviews/B082XY23D5/ref=cm_cr_arp_d_paging_btm_2?ie=UTF8&pageNumber=2", page.NextPageUri.ToString());
            Assert.Equal(10, page.CustomerReviews.Count);
        }