veri

mail@pastecode.io avatar
unknown
csharp
4 years ago
2.0 kB
12
Indexable
Never
private void button1_Click(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            for (int i = 0; i < 5; i++)
            {
                try
                {
                    Uri url = new Uri("https://blog.konusarakogren.com/en-cok-kullanilan-ingilizce-kelimeler-ve-anlamlari/#a-harfi-ile-baslayan-ingilizce-kelimeler");
                    //Uri url = new Uri("https://kelimeler.net/ce-kelimesinin-anlami-nedir");
                    client.Encoding = Encoding.UTF8;
                    string html = client.DownloadString(url);
                    html = html.Replace("&#220;", "Ü");
                    html = html.Replace("&#199;", "Ç");
                    html = html.Replace("&#214;", "Ö");
                    html = html.Replace("&#231;", "ç");
                    html = html.Replace("&#252;", "ü");
                    html = html.Replace("&#246;", "ö");
                    html = html.Replace("&#39;", "'");
                    html = html.Replace("&quot;", "");
                    html = html.Replace("&#238;", "î");
                    html = html.Replace("&#8211;", "-");
                    html = html.Replace("&#226;", "â");
                    html = html.Replace("<gcse:searchresults>", "");
                    HtmlAgilityPack.HtmlDocument dokuman = new HtmlAgilityPack.HtmlDocument();
                    dokuman.LoadHtml(html);
                    HtmlNodeCollection basliklar = dokuman.DocumentNode.SelectNodes("/html/body/div[1]/div[2]/div[1]/main/article/ul[1]/li["+i+1+"]/text()");

                    foreach (var baslik in basliklar)
                    {
                        dataGridView1.Rows.Add(baslik.InnerText);

                    }

                    label2.Text = dataGridView1.RowCount.ToString();

                }
                catch (Exception)
                {

                }
               // MessageBox.Show("Hepsi Bitti");
            }