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

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -