S
S
SunNy5462020-05-14 16:57:37
C++ / C#
SunNy546, 2020-05-14 16:57:37

Hello guys who worked with selemiun, what's wrong?

5ebd4c3fb9be1693201097.jpeg

private void button2_Click(object sender, EventArgs e)
        {
            Browser.Navigate().GoToUrl($"https://steamcommunity.com/market/search?appid=730#p1_popular_desc");

            //Переключение страницы на торговой площадке Steam и сбор вещей
            for (int page = 1; page < 1506; page++)
            {
                for (int i = 0; i < 10; i++)
                {   
                    //File.WriteAllText(@"D:\Users\SunNy\Desktop\resellPrice.txt");
                    IWebElement SteamContainer = Browser.FindElement(By.Id("searchResultsRows"));
                    List<IWebElement> Items = SteamContainer.FindElements(By.ClassName("market_listing_row market_recent_listing_row market_listing_searchresult")).ToList();
                    System.Threading.Thread.Sleep(2000);
                    Items[i].Click();

                    String PriceAuto = "";
                    String PriceDefolt = "";

                    System.Threading.Thread.Sleep(2000); 
                    List<IWebElement> SellAuto = Browser.FindElements(By.ClassName("market_commodity_buyrequests")).ToList();
                    // Цена автопокупки
                    for (int j = 0; j < SellAuto.Count; j++)
                    {
                        if (SellAuto[j].Displayed)
                        {
                            PriceAuto = SellAuto[j].Text;
                            String PriceAutoToText = System.Text.RegularExpressions.Regex.Match(PriceAuto, @"[0-9]+\,?[0-9]*").Value;
                        }
                    }
                    List<IWebElement> SellDefolt = Browser.FindElements(By.ClassName("market_commodity_forsale")).ToList();
                    // Дефолтная цена
                    for (int x = 0; x < SellDefolt.Count; x++)
                    {
                        if (SellDefolt[x].Displayed)
                        {
                            PriceDefolt = SellDefolt[x].Text;
                            String PriceDefoltToText = System.Text.RegularExpressions.Regex.Match(PriceDefolt, @"[0-9]+\,?[0-9]*").Value;
                        }
                    }
                    // Считаем сколько разница между дефолт и автопокупкой
                    float PriceDifference = Single.Parse(PriceDefolt) - Single.Parse(PriceAuto);
                    Console.WriteLine(PriceDifference);
                }
                System.Threading.Thread.Sleep(1000);
                IWebElement pageSteam;
                pageSteam = Browser.FindElement(By.Id("searchResults_btn_next"));
                pageSteam.Click();
            }
        }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2020-05-14
@SunNy546

what's wrong

You have an error even in Russian says what's wrong. You don't have ten Items.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question