Beispiel #1
0
        public Book IslemYap(string rets, Book book)
        {
            string price = CsvExport.getBetween(rets, "<span class=\"a-color-base\">", "<");

            if (string.IsNullOrWhiteSpace(price))
            {
                price = price = CsvExport.getBetween(rets, "<span class=\"a-size-base a-color-price offer-price a-text-normal\">", "</span>");
            }
            if (string.IsNullOrWhiteSpace(price))
            {
                price = CsvExport.getBetween(rets, "<span id=\"priceblock_ourprice\" class=\"a-size-medium a-color-price\">", "</span>");
            }

            if (!string.IsNullOrWhiteSpace(price))
            {
                price = price.Replace("\n", "").Trim().Replace("ab ", "");
            }
            book.Price = price;

            // tablo fiyat
            string tablo = CsvExport.getBetween(rets, "<div class=\"a-section a-spacing-small a-spacing-top-small\">", "</div>");

            if (string.IsNullOrWhiteSpace(tablo))
            {
                tablo = CsvExport.getBetween(rets, "<div id=\"olp-sl-new-used\" class=\"a-section a-spacing-small a-spacing-top-small\">", "</div>");
            }

            if (!string.IsNullOrWhiteSpace(tablo))
            {
                var list = CsvExport.getBeetweenList(tablo, "<span class=\"olp-padding-right\"><a href=\"", "</span></span>");
                foreach (var l in list)
                {
                    if (l.ToLower().Contains("=new\""))
                    {
                        var tmp = CsvExport.getBetween(l, "=new\"");
                        if (!string.IsNullOrWhiteSpace(tmp))
                        {
                            book.NewCount = CsvExport.getBetween(tmp, ">", "</a>");
                            book.NewPrice = CsvExport.getBetween(tmp, "<span class='a-color-price'>");
                        }
                        continue;
                    }
                    if (l.ToLower().Contains("=used\""))
                    {
                        var tmp = CsvExport.getBetween(l, "=used\"");
                        if (!string.IsNullOrWhiteSpace(tmp))
                        {
                            book.UsedCount = CsvExport.getBetween(tmp, ">", "</a>");
                            book.UsedPrice = CsvExport.getBetween(tmp, "<span class='a-color-price'>");
                        }
                        continue;
                    }
                    if (l.ToLower().Contains("=collectible\""))
                    {
                        var tmp = CsvExport.getBetween(l, "=collectible\"");
                        if (!string.IsNullOrWhiteSpace(tmp))
                        {
                            book.CollectibleCount = CsvExport.getBetween(tmp, ">", "</a>");
                            book.CollectiblePrice = CsvExport.getBetween(tmp, "<span class='a-color-price'>");
                        }
                        continue;
                    }
                }
            }

            return(book);
        }
Beispiel #2
0
        public Book IslemYap(string rets, Book book)
        {
            string price = CsvExport.getBetween(rets, "<span class=\"a-color-base\">", "<");

            if (string.IsNullOrWhiteSpace(price))
            {
                price = CsvExport.getBetween(rets, "<span id=\"priceblock_ourprice\" class=\"a-size-medium a-color-price\">", "<");
            }
            price = CsvExport.getBetween(rets, "<span class=\"a-size-base a-color-price a-color-price\">", "</span>");
            if (string.IsNullOrWhiteSpace(price))
            {
                price = CsvExport.getBetween(rets, "<span class=\"a-color-base\">", "<");
            }

            if (!string.IsNullOrWhiteSpace(price))
            {
                price = price.Replace("\n", "").Trim().Replace("ab ", "");
            }
            book.Price = price;

            // tablo fiyat
            string tablo = CsvExport.getBetween(rets, "<span class=\"olp-");

            if (!string.IsNullOrWhiteSpace(tablo))
            {
                tablo = "<span class=\"olp-" + tablo;
                var list = CsvExport.getBeetweenList(tablo, "<a class=\"a-size-mini a-link-normal\" href=\"", " </a>");
                foreach (var l in list)
                {
                    if (l.ToLower().Contains("=new"))
                    {
                        var tmp = CsvExport.getBetween(l, "=new");
                        if (!string.IsNullOrWhiteSpace(tmp))
                        {
                            tmp           = tmp.Replace("\n", "");
                            book.NewCount = CsvExport.getBetween(tmp, "sr=\">", "<span").Trim();
                            book.NewPrice = CsvExport.getBetween(tmp, "</span>").Trim();
                        }
                        continue;
                    }
                    if (l.ToLower().Contains("=used"))
                    {
                        var tmp = CsvExport.getBetween(l, "=used");
                        if (!string.IsNullOrWhiteSpace(tmp))
                        {
                            tmp            = tmp.Replace("\n", "");
                            book.UsedCount = CsvExport.getBetween(tmp, "sr=\">", "<span").Trim();
                            book.UsedPrice = CsvExport.getBetween(tmp, "</span>").Trim();
                        }
                        continue;
                    }
                    if (l.ToLower().Contains("=collectible"))
                    {
                        var tmp = CsvExport.getBetween(l, "=collectible");
                        if (!string.IsNullOrWhiteSpace(tmp))
                        {
                            book.CollectibleCount = CsvExport.getBetween(tmp, ">", "</a>");
                            book.CollectiblePrice = CsvExport.getBetween(tmp, "<span class='a-color-price'>");
                        }
                        continue;
                    }
                }
            }

            return(book);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            try
            {
                var lines = new List <Book>();
                foreach (var country in countries)
                {
                    foreach (var product in products)
                    {
                        var url  = string.Format("https://www.amazon{1}/dp/{0}", product, country);
                        var rets = CsvExport.UrunDetay(url).GetAwaiter().GetResult();
                        if (rets != null)
                        {
                            BookManager bm;
                            var         book = new Book();
                            book.Url       = url;
                            book.TimeStamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            book.Asin      = product;
                            book.Country   = country;

                            // name
                            var productStr = CsvExport.getBetween(rets, "<h1 id=\"title\" class=\"a-size-large a-spacing-none\">", "</h1>\n</div>");
                            if (string.IsNullOrWhiteSpace(productStr))
                            {
                                productStr = CsvExport.getBetween(rets, "<h1 id=\"title\" class=\"a-size-large a-spacing-none\">", "</h1>");
                            }

                            if (!string.IsNullOrWhiteSpace(productStr))
                            {
                                var title = CsvExport.getBetween(productStr, "<span id=\"productTitle\" class=\"a-size-large\">", "</span>");
                                title = CsvExport.clearHtmlText(title);
                                title = title.Replace("\n", "").Trim();
                                var values = string.Join(" ", CsvExport.getBeetweenList(productStr, "<span class=\"a-size-medium a-color-secondary a-text-normal\">", "</span>").ToArray());
                                values    = CsvExport.clearHtmlText(values);
                                book.Name = title + " " + values;
                            }

                            if (product == "3811839217")// "3426652684") //"3815566355")
                            {
                                ;
                            }

                            if (country == ".de")
                            {
                                bm   = new BookManager(new De());
                                book = bm.IslemYap(rets, book);
                            }
                            else
                            if (country == ".fr")
                            {
                                bm   = new BookManager(new Fr());
                                book = bm.IslemYap(rets, book);
                            }
                            else
                            if (country == ".it")
                            {
                                bm   = new BookManager(new It());
                                book = bm.IslemYap(rets, book);
                            }
                            else
                            if (country == ".co.uk")
                            {
                                bm   = new BookManager(new Co());
                                book = bm.IslemYap(rets, book);
                            }
                            else
                            {
                                bm   = new BookManager(new Com());
                                book = bm.IslemYap(rets, book);
                            }

                            var line = string.Format("{0} {1} {2}", country, product, book.Price);
                            lines.Add(book);
                            Console.WriteLine(line);
                        }
                    }
                }

                if (lines.Count > 0)
                {
                    var sonuc = lines.Select(e => e).OrderBy(e => e.Asin).ToList();
                    var ret   = sonuc.ToHtmlTable();
                    File.WriteAllText("products.html", ret);
                }
            }
            catch (Exception ex)
            {
                string err = ex.Message;
            }
        }