Retrieve HtmlElement

本文关键字:HtmlElement Retrieve | 更新日期: 2023-09-27 18:31:32

<a href="/game.php?yo=120252&amp;screen=info_command&amp;id=1602691855&amp;type=own">
<span class="element1">
    Random text 
</span>

我正在使用带有集成Web浏览器的Windows-Forms-Application。有没有办法检索这个特定的HtmlElement?

对不起,我是新手,如果缺少一些信息,请告诉我。

Retrieve HtmlElement

using System.Linq;
...
var element1 = browser.Document.GetElementsByTagName("span")
      .Where(e => e.GetAttribute("class") == "element1")
      .FirstOrDefault();

如果没有找到element1,将null