c# - Get the value from a div using HtmlAgilityPack -


i trying value div using htmlagilitypack. htmlcode : enter image description here

i need value in news_content_container div class ca see in picture selected use code :

     var response1 = await http.getbytearrayasync("http://www.nsfund.ir/news?"+link);                 string source1 = encoding.getencoding("utf-8").getstring(response1, 0, response1.length - 1);                 source1 = webutility.htmldecode(source1);                 htmldocument resultat1 = new htmldocument();                 resultat1.loadhtml(source1);                var val = resultat1.documentnode.descendants().where   (x => (x.name == "div" && x.attributes["class"] != null && x.attributes["class"].value.contains("news_content_container"))).tolist().first().innertext;; 

but result empty .

try this

var response1 = await http.getbytearrayasync("http://www.nsfund.ir/news?"+link);                 string source1 = encoding.getencoding("utf-8").getstring(response1, 0, response1.length - 1);                 source1 = webutility.htmldecode(source1);                 htmldocument resultat1 = new htmldocument();                 resultat1.loadhtml(source1);                var val = resultat1.documentnode.selectsinglenode("//div[@class='news_content_container']").innertext; 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -