Esempio n. 1
0
        private static void crawler()
        {
            int take = 1;

            //string xml = await XmlTools.LoadSitemap();
            //Urlset urls = XmlTools.getUrls(xml);
            //string[] url = urls.urls.Where(x => x.loc.Contains("/products/")).Select(x => x.loc).ToArray();
            string[]        url      = XmlTools.GetUrls.Where(x => x.Contains("/products/") && x.Contains("/pumps/") && x.Length > x.IndexOf("/pumps/") + 7).Skip(30).Take(take).Select(x => x).ToArray();
            List <LProduct> products = new List <LProduct>();

            //System.IO.File.WriteAllLines(@"C:\Users\Behzad\Desktop\txt_lebold\Leybold.txt", url);
            wl("Loading ");
            foreach (var item in url)
            {
                int s = item.IndexOf("/pumps/");
                if (item.Length > s + 7)
                {
                    using (LeyboldHelper leybold = new LeyboldHelper())
                    {
                        var pr = leybold.GetProduct("https://www.leyboldproducts.com/products/oil-sealed-vacuum-pumps/vacube/2744/vacube-vq-800?c=16026");
                        products.Add(pr);
                        wl("|");
                    }
                }
            }
            //LoadSitemap("https://www.leyboldproducts.com/products/vacuum-pump-systems/fore-vacuum-pump-systems/ruta-pumpsystems-with/1507/ruta-wau-1001/sv-200/a");
            var j = JsonConvert.SerializeObject(products);

            w("\n");
            w(j);
            w("\n");
            w("\n");
            w("finish");
        }
Esempio n. 2
0
 private static void wp()
 {
     string[] urla = XmlTools.GetUrls.Where(x => x.Contains("/products/") && x.Contains("/pumps/") && x.Length > x.IndexOf("/pumps/") + 7).Select(x => x).Skip(14).Take(3).ToArray();
     foreach (string url in urla)
     {
         LProduct product = new LProduct();
         using (LeyboldHelper leybold = new LeyboldHelper())
         {
             product = leybold.GetProduct(url);
         }
         using (WooCommerce woo = new WooCommerce())
         {
             woo.createPost(product);
         }
     }
 }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            int?count = useCount;

            if (count.HasValue && count >= 0 && count < 4)
            {
                List <LProduct> products = new List <LProduct>();
                using (LeyboldHelper leybold = new LeyboldHelper())
                {
                    var pr = leybold.GetProduct(txtUrl.Text);
                    products.Add(pr);
                }
                var j = JsonConvert.SerializeObject(products, Formatting.Indented);
                richText1.Document.Blocks.Clear();
                richText1.Document.Blocks.Add(new Paragraph(new Run(j)));
                MessageBox.Show($"شما {count + 1} از 5 بار از برنامه استفاده کرده اید");
            }
            else
            {
                MessageBox.Show("تعداد دفعات مورد استفاده بیش از حد مجاز بوده است.");
            }
        }