private static void processGame(GameData game) { string gamePageURL = "http://www.metacritic.com/" + game.GamePageURL; try { Console.WriteLine("Downloading game data for {0}", game.GamePageURL); string pageString = pageString = wc.DownloadString(gamePageURL); HtmlDocument htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(pageString); game.Name = htmlDoc.DocumentNode.SelectSingleNode("//*[@id=\"main\"]/div/div[1]/h1/a/span").InnerText.Trim(); game.Platform = htmlDoc.DocumentNode.SelectSingleNode("//*[@id=\"main\"]/div/div[1]/h1/span/a/span").InnerText.Trim(); game.Developer = htmlDoc.DocumentNode.SelectSingleNode("//*[@id=\"main\"]/div/div[3]/div/div/div[2]/div[2]/div[2]/ul/li[1]/span[2]").InnerText.Trim(); game.Publisher = htmlDoc.DocumentNode.SelectSingleNode("//*[@id=\"main\"]/div/div[1]/div[2]/ul/li[1]/span[2]/a/span").InnerText.Trim(); game.ReleaseDate = htmlDoc.DocumentNode.SelectSingleNode("//*[@id=\"main\"]/div/div[1]/div[2]/ul/li[2]/span[2]").InnerText.Trim(); game.Genre = htmlDoc.DocumentNode.SelectSingleNode("//*[@id=\"main\"]/div/div[3]/div/div/div[2]/div[2]/div[2]/ul/li[2]/span[2]").InnerText.Trim(); game.Metascore = int.Parse(htmlDoc.DocumentNode.SelectSingleNode("//*[@id=\"main\"]/div/div[3]/div/div/div[2]/div[1]/div[1]/div/div/a/div/span").InnerText.Trim()); game.UserScore = float.Parse(htmlDoc.DocumentNode.SelectSingleNode("//*[@id=\"main\"]/div/div[3]/div/div/div[2]/div[1]/div[2]/div[1]/div/a/div").InnerText.Trim()); game.Rating = htmlDoc.DocumentNode.SelectSingleNode("//*[@id=\"main\"]/div/div[3]/div/div/div[2]/div[2]/div[2]/ul/li[4]/span[2]").InnerText.Trim(); processCriticReviews(game); } catch (Exception e) { Console.WriteLine(" ** Failed to download game data for {0} - {1} **", game.GamePageURL, e.Message); } }
private static void processCriticReviews(GameData game) { string gameCriticPageURL = "http://www.metacritic.com/" + game.GamePageURL + "/critic-reviews"; try { Console.WriteLine("Downloading game critic review data for {0}", gameCriticPageURL); string pageString = wc.DownloadString(gameCriticPageURL); HtmlDocument htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(pageString); CriticReview cr = new CriticReview(); cr.Reviewer = htmlDoc.DocumentNode.SelectSingleNode("//*[@id=\"main\"]/div[5]/div/ol/li[1]/div/div/div/div/div/div[1]/div[1]/div[1]/div[1]/a").InnerText.Trim(); cr.Score = int.Parse(htmlDoc.DocumentNode.SelectSingleNode("//*[@id=\"main\"]/div[5]/div/ol/li[1]/div/div/div/div/div/div[1]/div[1]/div[2]/div").InnerText.Trim()); game.CriticReviews.Add(cr); } catch (Exception e) { Console.WriteLine(" ** Failed to download critic review data for {0} - {1} **", game.GamePageURL, e.Message); } }