Esempio n. 1
0
 public static List<Gun> GetInventory(string sourceCode)
 {
     List<Gun> inventory = new List<Gun>();
     while (sourceCode.IndexOf("<div title=") != -1)
     {
         Gun inventoryGun = new Gun();
         //get name
         int nameStartIndex = sourceCode.IndexOf("<div title=") + 12;
         int nameEndIndex = sourceCode.IndexOf("\'", nameStartIndex);
         string gunName = sourceCode.Substring(nameStartIndex, nameEndIndex - nameStartIndex);
         inventoryGun.Name = gunName;
         //get id #
         int idStart = sourceCode.IndexOf("c-id=\'") + 6;
         int idEnd = sourceCode.IndexOf("\'", idStart);
         string idNumber = sourceCode.Substring(idStart, idEnd - idStart);
         //get price
         int priceStartIndex = sourceCode.IndexOf("c-val=\'") + 7;
         int priceEndIndex = sourceCode.IndexOf("'", priceStartIndex);
         string gunPrice = sourceCode.Substring(priceStartIndex, priceEndIndex - priceStartIndex);
         StringBuilder sb = new StringBuilder(gunPrice);
         sb.Insert(gunPrice.Length - 3, ".");
         string format = sb.ToString();
         double Price = Convert.ToDouble(format);
         inventoryGun.IdNumber = idNumber;
         inventoryGun.MarketPrice = Price;
         sourceCode = sourceCode.Substring(priceEndIndex);
         inventory.Add(inventoryGun);
     }
     return inventory;
 }
Esempio n. 2
0
 public static List<Gun> GetItems(int bot, string sourceCode)
 {
     List<Gun> poker = new List<Gun>();
     while (sourceCode.IndexOf("<div title=") != -1)
     {
         Gun addGun = new Gun();
         //get name of gun
         int nameStartIndex = sourceCode.IndexOf("<div title=") + 12;
         int nameEndIndex = sourceCode.IndexOf("\"", nameStartIndex);
         string gunName = sourceCode.Substring(nameStartIndex, nameEndIndex - nameStartIndex);
         addGun.Name = gunName;
         //get price
         int priceStartIndex = sourceCode.IndexOf("c-val=\'") + 7;
         int priceEndIndex = sourceCode.IndexOf("'", priceStartIndex);
         string gunPrice = sourceCode.Substring(priceStartIndex, priceEndIndex - priceStartIndex);
         StringBuilder sb = new StringBuilder(gunPrice);
         sb.Insert(gunPrice.Length - 3, ".");
         string format = sb.ToString();
         double Price = Convert.ToDouble(format);
         addGun.Bot = bot;
         addGun.MarketPrice = Price;
         sourceCode = sourceCode.Substring(priceEndIndex);
         poker.Add(addGun);
     }
     return poker;
 }
Esempio n. 3
0
        public static List<Gun> FindItems(List<Gun> testGun, bool Price)
        {
            DateTime current = DateTime.Today;
            string date = current.ToString("MMM");
            List<Gun> gunList = new List<Gun>();
            int counter = 0;
            foreach (Gun g in testGun)
            {
                string sourceCode = GetSource(g.Name);
                string interiorSource = sourceCode;
                string goingPriceSource = sourceCode;
                Gun addGun = new Gun();
                double price = g.MarketPrice;
                if (Price)
                {
                    int startIndex = sourceCode.IndexOf(date) + 20;
                    //this changes the month to the previous if the current is not found and states that the data is old
                    if (startIndex < 10)
                    {
                        date = current.AddMonths(-1).ToString("MMM");
                        startIndex = sourceCode.IndexOf(date) + 20;
                        addGun.Date = "Old";
                    }
                    else
                    {
                        addGun.Date = "Current";
                    }
                    while (sourceCode.IndexOf(date) != -1)
                    {
                        startIndex = sourceCode.IndexOf(date) + 20;
                        sourceCode = sourceCode.Substring(startIndex);
                        startIndex = 0;
                    }
                    int endIndex = sourceCode.IndexOf(",", startIndex);
                    string sPrice = sourceCode.Substring(startIndex, endIndex);
                    price = Convert.ToDouble(sPrice);

                }
                //find going rate
                double goingPrice = FindGoingPrice(interiorSource);
                addGun.IdNumber = g.IdNumber;
                addGun.GoingRate = goingPrice;
                addGun.Name = g.Name;
                addGun.MarketPrice = price;
                gunList.Add(addGun);
                counter++;
            }
            return gunList;
        }
Esempio n. 4
0
 private void btnLoadSingle_Click(object sender, EventArgs e)
 {
     if (txtSingle.Text != string.Empty)
     {
         int botNumber = Convert.ToInt32(txtBotNumber.Text.Trim());
         string test = txtSingle.Text.Trim();
         Gun addGun = new Gun();
         addGun.Name = test;
         addGun.Bot = botNumber;
         objSteamFilter.Add(addGun);
         objSteam = SteamScraper.FindItems(objSteamFilter, true);
         foreach (Gun g in objSteam)
         {
             for (int i = 0; i < objPoker.Count; i++)
             {
                 if (g.Name == objPoker[i].Name)
                 {
                     //Check my math
                     double difference = g.GoingRate - objPoker[i].MarketPrice;
                     double increase = difference / objPoker[i].MarketPrice * 100;
                     double result = Math.Round(increase, 2);
                     g.PercentChange = result;
                 }
             }
         }
         dgvSteam.DataSource = objSteam;
     }
 }