HtmlAgilityPack not working with IMDB

128 views Asked by At

It seems that it works with metacritic but imdb it is refusing. this is what i did (I use chrome) take a movie on IMDB. Right click on a title and inspect. then on the line where there is itemprop get the xpath. copy that xpath to this code. and i get a null refrence exeption. Here is my code

        string Url = "http://www.imdb.com/title/tt4972582/?ref_=tt_rec_tt";
        HtmlWeb web = new HtmlWeb();
        HtmlDocument doc = new HtmlDocument();
        doc.OptionFixNestedTags = true;
        doc = web.Load(Url);


        HtmlNode metascore = doc.DocumentNode.SelectSingleNode("//*[@id=\"title-overview-widget\"]/div[2]/div[2]/div/div[2]/div[2]/h1");

        string test = metascore.InnerText;

It is only with IMDB i think it has someting to do with there website, but i am not sure. I got it once to work but after that it stop. EDIT: Okay i found out something, in a new console base application it works but in my database program it refuses and gives me a error the whole time.

0

There are 0 answers