c# - Get the href innertext with HtmlAgilityPack -


i trying create news agent news websites.so have use html parser htmlagilitypack .so here ca see code :

public async void parsing(string website) {     httpclient http = new httpclient();     var response = await http.getbytearrayasync(website);     string source = encoding.getencoding("utf-8").getstring(response, 0, response.length - 1);     source = webutility.htmldecode(source);     htmldocument resultat = new htmldocument();     resultat.loadhtml(source);     list<htmlnode> toftitle = resultat.documentnode.descendants().where       (x => (x.name == "div" && x.attributes["class"] != null && x.attributes["class"].value.contains("latest-news"))).tolist();     var li = toftitle[0].descendants("li").tolist();     foreach (var item in li)     {         var link = item.descendants("a").tolist()[0].getattributevalue("href", null);         var img = item.descendants("img").tolist()[0].getattributevalue("src", null);     } } 

here html code should parsed :

<a href="/news?p_p_id=56_instance_tvzmolp4zfgh&amp;_56_instance_tvzmolp4zfgh_mode=news&amp;_56_instance_tvzmolp4zfgh_newsid=3153832&amp;p_p_state=maximized">› پانل «بررسي سازوکارهاي تأمين منابع مالي براي توسعۀ فناوري» به‌عنوان پانل برتر پنجمين کنفرانس بين‌المللي و نهمين کنفرانس ملي مديريت فناوري معرفي شد</a>   <a href="/news?p_p_id=56_instance_tvzmolp4zfgh&amp;_56_instance_tvzmolp4zfgh_mode=news&amp;_56_instance_tvzmolp4zfgh_newsid=3135970&amp;p_p_state=maximized">› فرآیند و فرم درخواست استفاده از تسهیلات حمایتی بلاعوض صندوق نوآوری و شکوفایی جهت حضور شرکت های دانش بنیان در جایزه ملی مدیریت فناوری و نوآوری</a> 

so problem can href link not href value .i mean can news url not title پانل «بررسي سازوکارهاي تأمين منابع مالي براي توسعۀ فناوري» به‌عنوان پانل برتر پنجمين کنفرانس بين‌المللي و نهمين کنفرانس ملي مديريت فناوري معرفي شد.

how can ?

i should use code innertext of href :

string tistle = item.descendants("a").tolist()[0].innertext; 

Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -