c# - Get value between html tags Xpath and HtmlAgility -


so far trying retrieve text between html tags website....

say instance need extract out text between these span tags how go that, receiving error stating "the object reference not set instance of object" here html

there html code prior portion here; don't know if should make difference.

<div class="thumbnail-details"> <ul>     <li> … </li>     <li class="product-title">         <span class="thumbnail-details-grey">the blaster portable wireless speaker in black</span>     </li>     <li> … </li> </ul> </div> 

so far c# code

    htmlweb hw = new htmlweb();         htmlagilitypack.htmldocument htmldoc = hw.load(@"http://www.karmaloop.com/browse.htm#pgroup=1");         if (htmldoc.documentnode != null)         {             foreach (htmlnode text in htmldoc.documentnode.selectnodes("//span[@class='thumbnail-details-grey']/text()"))             {                 console.writeline(text.innertext);             } 

can here, want extract out "the blaster portable wireless speaker in black". helpful, in advance.

your code works fine, you'll have load right page work. page loading uses ajax request load results see in browser.

so instead of url using have use:

htmldocument htmldoc = hw.load(@"http://www.karmaloop.com/browse?pgroup=1&ajax=true&version=2"); 

then code works. i'm still looking place request gets put together...

but query looks rather easy guess. example page http://www.karmaloop.com/browse.htm#pdept=11&pagesize=30&pgroup=1 request url http://www.karmaloop.com/browse?pdept=11&pagesize=30&pgroup=1&ajax=true&version=2. have use url , build new 1 starting after #.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -