2

I'm extremely new to C# and was having a lot of trouble with this, I got the idea from another post I saw on stack overflow that was talking about grabbing data from sites and I wanted to try it so I used the code they posted and tried fiddling with it to make it work but i'm having no luck!

using HtmlAgilityPack;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MetaCriticParser
{
    class Program
    {
        static void Main(string[] args)
        {
            protected void Page_Loader(object sender, EventArgs e)
            {



                string url = "https://www.pcgamer.com/red-dead-redemption-2-review/";
                var web = new HtmlAgilityPack.HtmlWeb();
                HtmlDocument doc = web.Load(url);

                string metascore = doc.DocumentNode.SelectNodes("/html/body/div[5]/article/div[2]/section/div[4]/div[3]/div[1]/div/span")[0].InnerText;
                Console.WriteLine(metascore);

            }




        }
    }
}

I'm basically trying to grab a review score from pcgamer and it gives me this error in the console:

Unhandeled Exception: System.NullRefrenceException: object reference not set to an instance of an object, at MetaCriticParser.Program.main(String[ args) in line 19

0 Answers0