S
S
SunNy5462020-05-14 17:53:16
C++ / C#
SunNy546, 2020-05-14 17:53:16

How to make it go to the next for, process all 10 things on the page for me, throw it into txt or sql?

Of course, I’m stupid, but how to implement it so that it goes to the next for, processes all 10 things on the page for me, throws it into txt or sql (a friend said to do it through FrameworkEntity), but I didn’t understand xdd.
5ebd5b01ac34a107976030.png

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++)
            {
                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();
                
                for (int i = 0; i < Items.Count; i++)
                {   
                    
                    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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question