0

I am trying to scrape a website and get a URL from it, I am using htmlagilitypack and the code below:

HtmlWeb hw = new HtmlWeb();
HtmlAgilityPack.HtmlDocument doc = hw.Load("http://putlocker.ist/scorpion-season-1-episode-1/");

foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//[@id='vplayer_media']/video"))
{
    string whatever = link.OuterHtml;
    textBox1.Text = whatever;
}

I used opera's developer tools to copy the XPath which came out as this:

//*[@id="vplayer_media"]/video

I couldn't use it because of double quotes so I replaced it with

@"//*[@id=""vplayer_media""]/video" 

but I get the error:

Object reference not set to an instance of an object

What am I doing wrong?

1 Answers1

0

Escape the double-quotes in your xpath:

"//[@id=\"vplayer_media\"]/video"

Or use double-double-quotes with a 'literal'

@"//[@id=""vplayer_media""]/video"
PhonicUK
  • 13,486
  • 4
  • 43
  • 62