Yazılım.
CevapSitesi.com Beta!
Çözüm Noktası
Bu siteyi Facebook, Twitter, Google+ veya e-posta ile paylaşın.
| Sorular | Makaleler | Üyeler | Etiketler  | İletişim
Soru sormak ya da cevap vermek için;
giriş yapın veya üye olun.

Sosyal medya hesaplarınızla da giriş yapabilirsiniz.

Soru Geçmişi

«« Soruya geri dön
22.01.24 14:55
c# döngü ile xpath değiştirmek
merhaba bu Merhaba. Bu projem çalısıyor ama sadece 1 bilgi alabiliyorum döngü alabiliyorum. Döngü ile xpath ın içini değiştirebilirmiyim acaba şimdiden teşekkürler acaba?Şimdiden teşekkürler. /html/body/div[3]/div/div[3]/div/div[1]/div[1]/div[1]/div[4]/table/tbody/tr[1]/td[2]/div/span /html/body/div[3]/div/div[3]/div/div[1]/div[1]/div[1]/div[4]/table/tbody/tr[2]/td[2]/div/span /html/body/div[3]/div/div[3]/div/div[1]/div[1]/div[1]/div[4]/table/tbody/tr[3]/td[2]/div/span using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Net; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using HtmlAgilityPack; namespace WindowsFormsApp8 { &nbsp; &nbsp; public partial class Form1 : Form &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; { public Form1() &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { InitializeComponent(); &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } // döngü durumu &nbsp; &nbsp; &nbsp; &nbsp; bool loop_status = true; &nbsp; &nbsp; &nbsp; &nbsp; private void button1_Click(object sender, EventArgs e) &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { CheckForIllegalCrossThreadCalls = false; // cross-thread hatasını önler &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Thread abc = new Thread(launch); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; abc.Start(); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; } // ana işlem &nbsp; &nbsp; &nbsp; &nbsp; private void launch() &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { while (loop_status) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { for (int i = 0; i <= 9999; i++) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { label2.Text = (i.ToString());//sayım yapıyor &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int j = 0; j <= 11; j++) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { var url = new Uri("https://canlidoviz.com/kripto-paralar"); // url oluştruduk &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WebClient client = new WebClient(); // siteye erişim için client tanımladık &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var html = client.DownloadString(url); //sitenin html lini indirdik &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); //burada HtmlAgilityPack Kütüphanesini kullandık &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; doc.LoadHtml(html); // indirdiğimiz sitenin html lini oluşturduğumuz dokumana dolduruyoruz &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var mlk = doc.DocumentNode.SelectNodes("/html/body/div[3]/div/div[3]/div/div[1]/div[1]/div[1]/div[4]/table/tbody/tr[1]/td[2]/div/span")[0]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; label1.Text = (mlk.InnerHtml.ToString()); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Thread.Sleep(1000 - DateTime.Now.Millisecond); // sistem zamanına göre 1 saniyeyi milisaniye olarak eşleştirip sleep uygular. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (loop_status == false) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { break; // for döngüsünü durdurur ve main loop durur. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; } } } } } private void button2_Click(object sender, EventArgs e) &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loop_status = false; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; } } { loop_status = false; } } }
Ekleyen: misafir
Değiştiren: cevapsitesi
18.01.24 16:21
c# döngü ile xpath değiştirmek
merhaba bu projem çalısıyor ama sadece 1 bilgi alabiliyorum döngü ile xpath ın içini değiştirebilirmiyim acaba şimdiden teşekkürler /html/body/div[3]/div/div[3]/div/div[1]/div[1]/div[1]/div[4]/table/tbody/tr[1]/td[2]/div/span /html/body/div[3]/div/div[3]/div/div[1]/div[1]/div[1]/div[4]/table/tbody/tr[2]/td[2]/div/span /html/body/div[3]/div/div[3]/div/div[1]/div[1]/div[1]/div[4]/table/tbody/tr[3]/td[2]/div/span using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Net; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using HtmlAgilityPack; namespace WindowsFormsApp8 {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }                  // döngü durumu         bool loop_status = true;         private void button1_Click(object sender, EventArgs e)         {                         CheckForIllegalCrossThreadCalls = false; // cross-thread hatasını önler             Thread abc = new Thread(launch);             abc.Start();                      }         // ana işlem         private void launch()         {             while (loop_status)             {                 for (int i = 0; i <= 9999; i++)                 {                     label2.Text = (i.ToString());//sayım yapıyor                     for (int j = 0; j <= 11; j++)                     {                         var url = new Uri("https://canlidoviz.com/kripto-paralar"); // url oluştruduk                         WebClient client = new WebClient(); // siteye erişim için client tanımladık                         var html = client.DownloadString(url); //sitenin html lini indirdik                         HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); //burada HtmlAgilityPack Kütüphanesini kullandık                         doc.LoadHtml(html); // indirdiğimiz sitenin html lini oluşturduğumuz dokumana dolduruyoruz                         var mlk = doc.DocumentNode.SelectNodes("/html/body/div[3]/div/div[3]/div/div[1]/div[1]/div[1]/div[4]/table/tbody/tr[1]/td[2]/div/span")[0];                                                  label1.Text = (mlk.InnerHtml.ToString());                                                 Thread.Sleep(1000 - DateTime.Now.Millisecond); // sistem zamanına göre 1 saniyeyi milisaniye olarak eşleştirip sleep uygular.                         if (loop_status == false)                         {                             break; // for döngüsünü durdurur ve main loop durur.                         }                     }                 }             }         }         private void button2_Click(object sender, EventArgs e)         {             loop_status = false;                    }     } }
Ekleyen: misafir

En fazla 3 eski durum gösterilir.