Exemple #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);
        }
Exemple #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);
        }
Exemple #3
0
 public Task StartTask(string combination)
 {
     Task = Task.Factory.StartNew(new Action <object>((workedProxy) =>
     {
         string workedProxyString = string.Empty;
         if (workedProxy != null)
         {
             workedProxyString = workedProxy.ToString();
         }
         string correctProxy     = string.Empty;
         bool connectionAccepted = false;
         do
         {
             if (string.IsNullOrEmpty(workedProxyString))
             {
                 correctProxy  = WebHelper.GetRandomProxyAddress();
                 proxiedClient = WebHelper.CreateProxiedClient(correctProxy);
             }
             else
             {
                 correctProxy = workedProxyString;
             }
             if (string.IsNullOrEmpty(correctProxy))
             {
                 Debug.WriteLine("Return because proxy is null");
                 return;
             }
             try
             {
                 proxiedClient.DownloadData(WebHelper.amazonPageUrl);
                 connectionAccepted = true;
                 workedProxyAddress = correctProxy;
             }
             catch (Exception ex)
             {
                 WebHelper.Proxies.TryRemove(correctProxy, out int value);
                 workedProxyAddress = string.Empty;
                 workedProxyString  = string.Empty;
                 Debug.WriteLine(WebHelper.Proxies.Count);
             }
         } while (!connectionAccepted);
         SearchItemOnPage(combination);
     }), workedProxyAddress);
     return(Task);
 }