Get href link by ID webBrowser1 c#

2020-07-30 05:10发布

问题:

if a have id and i get text i use this

var text = webBrowser1.Document.GetElementById("id").InnerText;

how can I get the link href knowing the id

Html

<a id="link11" href="/torrent_details/386387353/ubuntu?tab=summary" data-dynamite-selected="true"><b>ubuntu</b>-12.04-desktop-i386.iso</a>

回答1:

string href = webBrowser1.Document.GetElementById("id").GetAttribute("href");


回答2:

try this

    webBrowser1.Document.GetElementById("link11").GetAttribute("href")