我在尝试从 Web 文档中提取超链接时遇到问题!
我尝试使用的方法如下所示:
HtmlElementCollection ht = wb.Document.Links;
foreach (HtmlElement item in ht)
{
if (item.GetAttribute("href").Contains("name"))
{
linkList.Add(item.GetAttribute("href"));
}
}
执行此代码时,我收到错误“指定的演员表无效”。我想问题出在事实上,执行此代码的方法是在与 webbrowser 不同的线程上调用的。在同一个线程上,我调用该方法没有问题。