async private void updatebuyorders() { int count3 = 1; for (int i = 0; i < buyorderlist.Count; i++) { play3 temp = buyorderlist.ElementAt(i); webBrowser2.Navigate("http://theshownation.com/marketplace/listing?item_ref_id=" + temp.ID); await Task.Delay(TimeSpan.FromSeconds(2)); HtmlElementCollection temas = webBrowser2.Document.GetElementsByTagName("INPUT"); foreach (HtmlElement fff in temas) { if (fff.OuterHtml.Contains("price") && fff.OuterHtml.Contains("hidden")) { String price = fff.OuterHtml.Substring((fff.OuterHtml.IndexOf("ue=\"") + 4), (fff.OuterHtml.IndexOf("\">") - (fff.OuterHtml.IndexOf("ue=\"") + 4))); if (count3 == 1) { temp.BuyNow = price; count3++; } else if (count3 == 2) { temp.SellNow = price; count3 = 1; } } } buyorderlist[i] = temp; } updatebuygrid(); }
async private void button7_Click(object sender, EventArgs e) { dataGridView3.DataSource = null; dataGridView3.Rows.Clear(); dataGridView3.Columns.Clear(); sellorderlist.Clear(); dataGridView4.DataSource = null; dataGridView4.Rows.Clear(); dataGridView4.Columns.Clear(); buyorderlist.Clear(); String url = "http://theshownation.com/marketplace/orders"; webBrowser3.Navigate(url); await Task.Delay(TimeSpan.FromSeconds(3)); HtmlElementCollection tables = webBrowser3.Document.GetElementsByTagName("TABLE"); int count = 1; String fa = ""; int index = 1; String id = ""; String name = ""; foreach (HtmlElement tbl in tables) { String temp = tbl.InnerText; HtmlElementCollection ff = tbl.GetElementsByTagName("td"); foreach (HtmlElement st in ff) { fa = st.InnerText; String fsd = st.InnerHtml; if (fa != null) { if (!fa.ElementAt(1).Equals(' ')) { fa = fa.Trim(); if (index == 1) { String tempo = fsd.Substring((fsd.IndexOf("d=") + 2), (fsd.IndexOf("\">") - (fsd.IndexOf("d=") + 2))); name = fa; id = tempo; index++; } else if (index == 2) { if (count == 1) { play3 player = new play3(); player.Name = name; player.ID = id; player.MyPrice = fa; buyorderlist.Add(player); } if (count == 2) { play3 player = new play3(); player.Name = name; player.ID = id; player.MyPrice = fa; sellorderlist.Add(player); } index++; } else if (index == 3) { index = 1; } } } } count++; } updatesellorders(); }