Beispiel #1
0
        public static void GetProductInfo()
        {
            XymogenScraper scraper = new XymogenScraper();
            Dictionary <long, XymogenProduct> prods = new Dictionary <long, XymogenProduct>();

            if (File.Exists(path))
            {
                prods = JsonConvert.DeserializeObject <Dictionary <long, XymogenProduct> >(File.ReadAllText(path));
            }

            using (WebClient wc = new WebClient())
            {
                for (int id = startingId; id < endingId; id++)
                {
                    System.Console.Write($"{id}\r");
                    if (!prods.Any(p => p.Value.Variants.Any(v => v.ProductID == id)))
                    {
                        XymogenProduct prod = scraper.ProcessPage(id);
                        if (prod != null)
                        {
                            if (!prods.ContainsKey(prod.MasterId))
                            {
                                prods.Add(prod.MasterId, prod);

                                string s = JsonConvert.SerializeObject(prods);
                                File.WriteAllText(path, s);
                            }
                            else
                            {
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            XymogenScraper.GetProductInfo();

            //         Shopify.Init();
            //List<Customer> c = Shopify.GetCustomers();
            //List<Order> l = Shopify.GetOrdersAsync().Result;

            //string start = JsonConvert.SerializeObject(l, Formatting.Indented,
            //	new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });

            //Customer c1 = c.FirstOrDefault(cu => cu.FirstName == "Darren" && cu.LastName == "Fink");
            //Order o1 = l.FirstOrDefault(o => o.Name == "ONW-1006");
            //Order o2 = l.FirstOrDefault(o => o.Name == "ONW-1007");
            //Order o3 = l.FirstOrDefault(o => o.Name == "ONW-1008");

            //if (o2 != null && o1 != null && o3 != null && c1 != null)
            //{
            //	c1.OrdersCount++;

            //	o1.Note = "";
            //	o1.OpenAsync().Wait();
            //	o1.Customer = c1;
            //	o1.UpdateAsync().Wait();
            //	o1.CloseAsync().Wait();

            //	o2.Note = "";
            //	o2.OpenAsync().Wait();
            //	o2.Customer = c1;
            //	o2.UpdateAsync().Wait();
            //	o2.CloseAsync().Wait();

            //	o3.Note = "";
            //	o3.OpenAsync().Wait();
            //	o3.Customer = c1;
            //	o3.UpdateAsync().Wait();
            //	o3.CloseAsync().Wait();

            //	string end = JsonConvert.SerializeObject(l, Formatting.Indented,
            //		new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
            //	Order o4 = Shopify.UpdateAsync(o1).Result;
            //	Order o5 = Shopify.UpdateAsync(o2).Result;
            //	Order o6 = Shopify.UpdateAsync(o3).Result;
            //	Customer c2 = Shopify.UpdateCustomer(c1);
            //}


            //			MasterScraper scraper = new MasterScraper();
            //			scraper.flatProducts();
            //scraper.Supplement();
            //scraper.Cleanup();
            //scraper.Supplement2();

            //List<OthoScraper.OrthoProduct>prods = scraper.GetProducts();
            //foreach (var prod in prods)
            //{
            //	foreach (var variant in prod.Variants)
            //	{
            //		if (variant.ProductNumber != null)
            //		{
            //			if (string.IsNullOrEmpty(variant.ImageUrl))
            //			{
            //				continue;
            //			}
            //			scraper.GetImage(variant.ImageUrl, variant.ProductNumber);

            //		}
            //	}

            //}



            //			BuildProduct(924);
            //			Supplement();
            //Supplement2();
        }