I want to get text from URL but text is not shown in source code. I can see it only in inspect element . Is there anyway, in C# to get the contents of Inspect element of the page. I try htmlagilitypack with c# but give null exception.
This is html code in inspect element:
<a id="href933" class="op-to-b-2" href="http://bux20.com/viewads/17EDB5BB6D1H7CVB69C55E7U554B5575EZ6H6O9524333CB46133315509H53735Z77444D5645OE4743136O967055276UV63933" target="_blank" i="933">
My C# code:
HtmlNodeCollection nodes1 = doc.DocumentNode.SelectNodes("//a[@class='op-to-b-2'][@href]");
I haven't used the HTML Agility pack myself, but I suspect it's just that your XPath expression is wrong. Try:
doc.DocumentNode.SelectNodes("//a[@class='op-to-b-2']/@href")
That will get name/value pairs. To get just the values, you can use:
doc.DocumentNode.SelectNodes("string(//a[@class='op-to-b-2']/@href)")
See more on this question at Stackoverflow