Exemplo n.º 1
0
        public bool IsProductDispatched(CustomWebClient client)
        {
            if (string.IsNullOrEmpty(Href))
            {
                return(false);
            }
            var html = client.DownloadString(Href);

            if (html.Contains("Dispatched from and sold by Amazon"))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        public AmazonItem InitPrice(CustomWebClient client)
        {
            if (string.IsNullOrEmpty(Href))
            {
                return(null);
            }
            var          html     = client.DownloadString(Href);
            HtmlDocument document = new HtmlDocument();

            document.LoadHtml(html);
            var tag = document.GetElementbyId("merchant-info");

            if (tag == null)
            {
                return(null);
            }

            HtmlNode price = document.DocumentNode.SelectSingleNode("//span[@id=\"priceblock_ourprice\"]");
            var      items = document.DocumentNode.SelectSingleNode("//*[@id='price']");

            if (price == null)
            {
                price = document.DocumentNode.SelectSingleNode("//*[@id='buyNewSection']/div/div/div/div[2]/a/div/div[2]/span/span");
            }
            if (price == null)
            {
                price = document.DocumentNode.SelectSingleNode("//*[@id='buyNewSection']/div/div/span/span");
            }
            if (price == null)
            {
                price = document.DocumentNode.SelectSingleNode("//*[@id='soldByThirdParty']/span[1]");
            }
            if (price == null)
            {
                price = document.DocumentNode.SelectSingleNode("//*[@id='oneTimeBuyBox']/div/div[1]/a/h5/div/div[2]/span");
            }
            if (price == null)
            {
                price = document.DocumentNode.SelectSingleNode("//*[@id=\"priceblock_ourprice\"]");
            }
            if (price == null)
            {
                Price = "0";
            }
            else
            {
                Price = price.InnerText;
            }
            return(this);
        }
Exemplo n.º 3
0
        private void SearchItemOnPage(string combination)
        {
            bool continueWork = true;
            int  pageNumber   = 1;

            do
            {
                string page = string.Empty;
                var    url  = WebHelper.CreateUrlToPageResults(combination, pageNumber);
                try
                {
                    page = proxiedClient.DownloadString(url);
                }
                catch (Exception ex)
                {
                    break;
                }
                var itemsOnPage = WebHelper.GetSearchAmazonResults(page, combination);
                if (itemsOnPage.ToList().Count == 0)
                {
                    break;
                }
                foreach (var item in itemsOnPage)
                {
                    var readyItem = item;
                    if (readyItem != null)
                    {
                        if (string.IsNullOrEmpty(readyItem.Price))
                        {
                            readyItem.InitPrice(proxiedClient);
                        }
                        readyItem.ClearPrice();
                        if (readyItem.IsProductDispatched(proxiedClient))
                        {
                            WebHelper.ResultList.Add(readyItem);
                        }
                        continueWork = false;
                        break;
                    }
                }
                pageNumber++;
            } while (continueWork);
        }