/// <summary> /// Retrieve the information from the game page info widget. /// </summary> /// <param name="info">Outbound GamePageInfo to store the info in.</param> /// <returns>True if the information was retrieved, otherwise False.</returns> public bool GetPageInfo(out GamePageInfo info) { info = new GamePageInfo() { aggregateRating = 0.0f, category = string.Empty, genres = new string[] { }, ratingCount = 0, tags = new string[] { } }; if (browserInterface.Navigate(gameUrl) == false) { return(false); } IWebElement infoElement = browserInterface.WaitForElement(By.ClassName("game_info_panel_widget")); if (infoElement == null) { return(false); } List <IWebElement> infoRows = infoElement.FindElements(By.TagName("tr")).ToList(); foreach (IWebElement infoRow in infoRows) { List <IWebElement> rowCells = infoRow.FindElements(By.TagName("td")).ToList(); IWebElement rowNameCell = rowCells[0]; string rowNameText = rowNameCell.GetAttribute("textContent"); switch (rowNameText) { case "Rating": ParseRatingCell(rowCells[1], ref info); break; case "Category": ParseCategoryCell(rowCells[1], ref info); break; case "Genre": ParseGenreCell(rowCells[1], ref info); break; case "Tags": ParseTagsCell(rowCells[1], ref info); break; } } //It seems on itch that only the Games category does //not display a category on the page. if (string.IsNullOrEmpty(info.category)) { info.category = "Games"; } return(true); }
public void Start(int startPage) { Console.WriteLine("Navigating to Itch..."); browserInterface.Navigate("https://itch.io"); Console.WriteLine("Log in and press enter to begin claiming."); Console.ReadLine(); GoToPage(startPage); ClaimCurrentPage(); while (GoToNextPage()) { ClaimCurrentPage(); } browserInterface.Close(); }