Exemplo n.º 1
0
        /// <summary>
        /// butona tiklandiginda DR'den veri ceken fonksiyon
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnVeriCekDergiDr_Click(object sender, EventArgs e)
        {
            AdminUser adminUserNesnesi = FormAnaEkran.AdminUserNesnesi;

            adminUserNesnesi.logAdmin(this, btnVeriCekDergiDr.Name, adminUserNesnesi.userName);
            WebClient client = new WebClient();
            Uri       url    = new Uri("https://www.dr.com.tr/Search?q=dergi#/page=1/sort=relevance,desc/categoryid=0/parentId=0/lg=undefined/price=-1,-1/ldir=h");

            client.Encoding = Encoding.UTF8;

            var    html1 = client.DownloadData(url);
            string html  = Encoding.UTF8.GetString(html1);

            HtmlAgilityPack.HtmlDocument dokuman = new HtmlAgilityPack.HtmlDocument();
            dokuman.LoadHtml(html);
            //HtmlNodeCollection basliklar = dokuman.DocumentNode.SelectNodes("//a[@href]");


            HtmlNodeCollection resim = dokuman.DocumentNode.SelectNodes("//img");

            HtmlNodeCollection ad = dokuman.DocumentNode.SelectNodes("//img[@src]");

            HtmlNodeCollection fiyat = dokuman.DocumentNode.SelectNodes("//span[@class='old-price']");

            DataGridViewImageColumn resim11 = new DataGridViewImageColumn();

            dgwDr.Columns.Add(resim11);

            resim11.ImageLayout = DataGridViewImageCellLayout.Stretch;


            for (int i = 0; i < fiyat.Count; i++)
            {
                gecicifiyat = "";
                var adi = ad[i + 1].Attributes["alt"].Value;
                adi = yerineKoy(adi);
                dgwDr.Rows.Add(adi.ToString());

                var fiyati = fiyat[i];
                for (int t = 0; t < fiyati.InnerLength - 3; t++)
                {
                    gecicifiyat += fiyati.InnerText[t];
                }
                dgwDr.Rows[i].Cells[1].Value = gecicifiyat;



                var imge = resim[i + 1].Attributes["src"].Value;

                imageİndirNet dmage = new imageİndirNet(imge);
                dmage.Download();
                try
                { dmage.SaveImage("D:\\dergiadi" + i + ".jpg", ImageFormat.Jpeg); }
                catch (Exception)
                {
                    dmage.SaveImage("D:\\dergiadi" + i + ".png", ImageFormat.Png);
                }

                try
                {
                    dgwDr.Rows[i].Cells[3].Value = Image.FromFile("D:\\dergiadi" + i + ".jpg");
                    dgwDr.Rows[i].Cells[2].Value = "D:\\dergiadi" + i + ".jpg";
                }
                catch (Exception)
                {
                    dgwDr.Rows[i].Cells[3].Value = Image.FromFile("D:\\dergiadi" + i + ".png");
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// butona tiklandiginda DR'den muzik cd ceken fonksiyon
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnVeriCekMusicCdDr_Click(object sender, EventArgs e)
        {
            AdminUser adminUserNesnesi = FormAnaEkran.AdminUserNesnesi;

            adminUserNesnesi.logAdmin(this, btnVeriCekMusicCdDr.Name, adminUserNesnesi.userName);
            WebClient client = new WebClient();
            Uri       url    = new Uri("https://www.dr.com.tr/Sectiklerimiz/Muzik");

            client.Encoding = Encoding.UTF8;

            var    html1 = client.DownloadData(url);
            string html  = Encoding.UTF8.GetString(html1);

            HtmlAgilityPack.HtmlDocument dokuman = new HtmlAgilityPack.HtmlDocument();
            dokuman.LoadHtml(html);

            HtmlNodeCollection resim = dokuman.DocumentNode.SelectNodes("//img[@class='lazyload']");

            HtmlNodeCollection ad = dokuman.DocumentNode.SelectNodes("//h3");

            HtmlNodeCollection fiyat   = dokuman.DocumentNode.SelectNodes("//span[@class='old-price']");
            HtmlNodeCollection sarkici = dokuman.DocumentNode.SelectNodes("//a[@class='who']");

            string duzeltme, gecicifiyat;

            DataGridViewImageColumn resim11 = new DataGridViewImageColumn();

            dgwDr.Columns.Add(resim11);
            resim11.ImageLayout = DataGridViewImageCellLayout.Stretch;

            for (int i = 0; i < fiyat.Count; i++)
            {
                gecicifiyat = "";
                var adi = ad[i];
                duzeltme = yerineKoy(adi.InnerText);
                dgwDr.Rows.Add(duzeltme.ToString());

                var fiyati = fiyat[i];
                for (int t = 0; t < fiyati.InnerLength - 3; t++)
                {
                    gecicifiyat += fiyati.InnerText[t];
                }
                dgwDr.Rows[i].Cells[1].Value = gecicifiyat;

                var kim = sarkici[i];
                duzeltme = yerineKoy(kim.InnerText);
                dgwDr.Rows[i].Cells[2].Value = duzeltme.ToString();

                var imge = resim[i].Attributes["data-src"].Value;

                dgwDr.Rows[i].Cells[3].Value = imge.ToString();

                imageİndirNet dmage = new imageİndirNet(imge);
                dmage.Download();
                try
                { dmage.SaveImage("D:\\cdadi" + i + ".jpg", ImageFormat.Jpeg); }
                catch (Exception)
                {
                    dmage.SaveImage("D:\\cdadi" + i + ".png", ImageFormat.Png);
                }

                try
                {
                    dgwDr.Rows[i].Cells[4].Value = Image.FromFile("D:\\cdadi" + i + ".jpg");
                    dgwDr.Rows[i].Cells[3].Value = "D:\\cdadi" + i + ".jpg";
                }
                catch (Exception)
                {
                    dgwDr.Rows[i].Cells[5].Value = Image.FromFile("D:\\cdadi" + i + ".png");
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// butona tiklandiginda DR'den veri ceken fonksiyon
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnVeriCekKitapDr_Click(object sender, EventArgs e)
        {
            AdminUser adminUserNesnesi = FormAnaEkran.AdminUserNesnesi;

            adminUserNesnesi.logAdmin(this, btnVeriCekKitapDr.Name, adminUserNesnesi.userName);
            Random    rastgele = new Random();
            WebClient client   = new WebClient();

            client.Encoding = System.Text.Encoding.GetEncoding(1254);
            Uri url = new Uri("https://www.dr.com.tr/CokSatanlar/Kitap#/page=2/sort=groups.group.displayorder,asc/categoryid=0/clog=4020/parentId=0/price=-1,-1");

            client.Encoding = Encoding.UTF8;



            Encoding.GetEncoding("iso-8859-9");

            var    html1 = client.DownloadData(url);
            string html  = Encoding.UTF8.GetString(html1);

            HtmlAgilityPack.HtmlDocument dokuman = new HtmlAgilityPack.HtmlDocument();
            dokuman.LoadHtml(html);
            HtmlNodeCollection basliklar = dokuman.DocumentNode.SelectNodes("//a[@href]");

            HtmlNodeCollection sayfa = dokuman.DocumentNode.SelectNodes("//a[@title]");

            HtmlNodeCollection resim = dokuman.DocumentNode.SelectNodes("//img[@class='lazyload']");

            HtmlNodeCollection ad      = dokuman.DocumentNode.SelectNodes("//div[@class='cell']");
            HtmlNodeCollection fiyat   = dokuman.DocumentNode.SelectNodes("//span[@class='old-price']");
            HtmlNodeCollection yazar   = dokuman.DocumentNode.SelectNodes("//a[@class='who']");
            HtmlNodeCollection yayinci = dokuman.DocumentNode.SelectNodes("//a[@class='who mb10']");
            HtmlNodeCollection tipi    = dokuman.DocumentNode.SelectNodes("//div[@class='cell']");
            //HtmlNodeCollection sayfa=dokuman.DocumentNode.SelectNodes("//div[@style]");

            string adi, duzeltme, tpi;



            for (int i = 0; i < ad.Count; i++)
            {
                gecicifiyat = "";
                adi         = ad[i].Attributes["data-name"].Value;
                adi         = yerineKoy(adi);

                dgwDr.Rows.Add(adi.ToString());

                var fiyati = fiyat[i];
                for (int t = 0; t < fiyati.InnerLength - 3; t++)
                {
                    gecicifiyat += fiyati.InnerText[t];
                }
                dgwDr.Rows[i].Cells[1].Value = gecicifiyat;

                var yazari = yazar[i];
                duzeltme = yerineKoy(yazari.InnerText);
                dgwDr.Rows[i].Cells[2].Value = duzeltme;

                var yayincisi = yayinci[i];
                duzeltme = yerineKoy(yayincisi.InnerText);
                dgwDr.Rows[i].Cells[3].Value = duzeltme;

                dgwDr.Rows[i].Cells[4].Value = rastgele.Next(31, 738);


                var imge = resim[i].Attributes["data-src"].Value;

                tpi = tipi[i].Attributes["data-category"].Value;
                tpi = yerineKoy(tpi);
                dgwDr.Rows[i].Cells[6].Value = tpi.ToString();

                imageİndirNet dmage = new imageİndirNet(imge);
                dmage.Download();
                try
                { dmage.SaveImage("D:\\Resimadi" + i + ".jpg", ImageFormat.Jpeg); }
                catch (Exception)
                {
                    dmage.SaveImage("D:\\Resimadi" + i + ".png", ImageFormat.Png);
                }

                try
                {
                    dgwDr.Rows[i].Cells[7].Value = Image.FromFile("D:\\Resimadi" + i + ".jpg");

                    dgwDr.Rows[i].Cells[5].Value = "D:\\Resimadi" + i + ".jpg";
                }
                catch (Exception)
                {
                    dgwDr.Rows[i].Cells[7].Value = Image.FromFile("D:\\Resimadi" + i + ".png");
                }
            }
            var img = resim[8].Attributes["data-src"].Value;
        }