c#-Windows窗体-如何在列表框中查找href更多链接?
www.stackoverflow.com请在那里登记href=“link” 我只是想要一个好的解决方案。如何可能在我的列表框中收到所有href链接 例如,在我的网站下面显示这样的代码 a href="stackoverflow/questions/31928301/hard-dropping-pieces-in-tetris-like-game" class="question-hyperlink" title="the hard-drop after clearing the ...">tetris-like gamec#-Windows窗体-如何在列表框中查找href更多链接?,c#,regex,split,webbrowser-control,C#,Regex,Split,Webbrowser Control,www.stackoverflow.com请在那里登记href=“link” 我只是想要一个好的解决方案。如何可能在我的列表框中收到所有href链接 例如,在我的网站下面显示这样的代码 a href="stackoverflow/questions/31928301/hard-dropping-pieces-in-tetris-like-game" class="question-hyperlink" title="the hard-drop after clearing the ...">te
试试这样的
HtmlElementCollection bdColl = webBrowser1.Document.GetElementsByTagName("a");
foreach (HtmlElement bdEl in bdColl)
{
if (bdEl.GetAttribute("href") != null)
listBox1.Add(bdEl.GetArttribute("href"));
}
谢谢你的帮助,我从这个问题上得到了很好的解决方案。这对我的工作目标很有帮助。 a href="https://physics.stackexchange.com/questions/199602/will-drinking-ice-cold-water-and-eating-cold-food-cause-weight-loss-over-a-peri" class="js-gps-track" data-gps-track="site.switch({ item_type:8, target_site:151 }); posts_hot_network .click({ item_type:2, location:8 })">Will drinking ice food cause weight loss (over a period of time)? a href="https://unix.stackexchange.com/questions/222368/get-date-of-next-saturday-from-a-given-date" class="js-gps-track" data-gps-track="site.switch({ item_type:8, target_site:106 }); posts_hot_network.click({ item_type:2, location:8 })">Get date of next Saturday from a given date
HtmlElementCollection bdColl = webBrowser1.Document.GetElementsByTagName("a");
foreach (HtmlElement bdEl in bdColl)
{
if (bdEl.GetAttribute("href").Contains("watch"))
listBox1 = bdEl.OuterHtml.Split('"')[9];
}
HtmlElementCollection bdColl = webBrowser1.Document.GetElementsByTagName("a");
foreach (HtmlElement bdEl in bdColl)
{
if (bdEl.GetAttribute("href") != null)
listBox1.Add(bdEl.GetArttribute("href"));
}