Пример #1
0
        async private void updatesearchlist(int X, String min, String max, String series)
        {
            for (int i = 1; i <= X; i++)
            {
                String urler = "http://theshownation.com/marketplace/search?page=" + i + "&main_filter=MLB Cards&min_price=" + min + "&max_price=" + max + series;
                webBrowser2.Navigate(urler);
                await Task.Delay(3000);

                var pager = Dcsoup.Parse(webBrowser2.DocumentText);
                var tds   = pager.Select("td");
                int count = 0;
                foreach (var td in tds)
                {
                    if (count == 3)
                    {
                        var    what       = td.Select("a[href*=listing]");
                        String whatone    = what.ElementAt(0).OuterHtml;
                        int    beg        = whatone.IndexOf("id=") + 3;
                        String id         = whatone.Substring(beg, 5);
                        var    yes        = td.Select("input[name*=price]");
                        int    start      = yes.ElementAt(0).OuterHtml.IndexOf("ue=\"") + 4;
                        int    end        = yes.ElementAt(0).OuterHtml.IndexOf("\">");
                        String buystring  = yes.ElementAt(0).OuterHtml.Substring(start, (end - start));
                        int    end1       = yes.ElementAt(1).OuterHtml.IndexOf("\">");
                        String sellstring = yes.ElementAt(1).OuterHtml.Substring(start, (end1 - start));
                        String name       = what.ElementAt(0).Text;
                        double profit     = double.Parse(buystring) - double.Parse(sellstring) - (double.Parse(buystring) * .1);
                        profit = Math.Round(profit, 0);
                        play2 play = new play2();
                        play.Name    = name;
                        play.ID      = id;
                        play.BuyNow  = buystring;
                        play.SellNow = sellstring;
                        play.Profit  = profit;
                        searchlist.Add(play);
                    }
                    count++;
                    if (count == 4)
                    {
                        count = 0;
                    }
                }
            }
            List <play2> templist = searchlist.OrderByDescending(o => o.Profit).ToList();

            dataGridView2.DataSource        = templist;
            dataGridView2.RowHeadersVisible = false;
            dataGridView2.Columns.Remove("ID");
            dataGridView2.AutoResizeColumns();
            dataGridView2.AutoResizeRows();
        }
Пример #2
0
        //previous it had String X, switching to int for now
        async private void updatewatchlist(int X)
        {
            for (int i = 1; i <= X; i++)
            {
                webBrowser2.Navigate("http://theshownation.com/marketplace/watchlist?page=" + i);
                await Task.Delay(3000);

                String        site  = webBrowser2.DocumentText;
                String        temp  = "<H2>";
                String        temp1 = "listing?item_ref_id=";
                String        temp2 = "<INPUT name=\"price\" type=\"hidden\" value=";
                StringReader  read  = new StringReader(site);
                StringBuilder what  = new StringBuilder();
                String        line;
                while ((line = read.ReadLine()) != null)
                {
                    if (line.Contains(temp) || line.Contains(temp1) || line.Contains(temp2))
                    {
                        what.AppendLine(line);
                    }
                }
                StringReader read2   = new StringReader(what.ToString());
                String       name    = "";
                String       id      = "";
                String       buynow  = "";
                String       sellnow = "";
                int          count   = 1;
                while ((line = read2.ReadLine()) != null)
                {
                    if (count == 1)
                    {
                        name = line.Substring(4, (line.IndexOf(" <") - 4));
                        count++;
                    }
                    else if (count == 2)
                    {
                        id = line.Substring((line.Length - 12), (line.IndexOf("\">") - (line.Length - 12)));
                        count++;
                    }
                    else if (count == 3)
                    {
                        buynow = line.Substring(41, ((line.IndexOf(">") - 1) - 41));
                        count++;
                    }
                    else if (count == 4)
                    {
                        sellnow = line.Substring(41, ((line.IndexOf(">") - 1) - 41));
                        play2 play = new play2();
                        play.Name    = name;
                        play.ID      = id;
                        play.BuyNow  = buynow;
                        play.SellNow = sellnow;
                        double profit = double.Parse(buynow) - double.Parse(sellnow) - (double.Parse(buynow) * .1);
                        profit      = Math.Round(profit, 0);
                        play.Profit = profit;
                        watchlist.Add(play);
                        count = 1;
                    }
                }
            }
            List <play2> templist = watchlist.OrderByDescending(o => o.Profit).ToList();

            dataGridView1.DataSource        = templist;
            dataGridView1.RowHeadersVisible = false;
            dataGridView1.Columns.Remove("ID");
            dataGridView1.AutoResizeColumns();
            dataGridView1.AutoResizeRows();
        }