C# 使用WebBrowser检查滤芯

C# 使用WebBrowser检查滤芯,c#,null,element,document,inspect,C#,Null,Element,Document,Inspect,我需要在winamax live博彩页面上获取赔率。唯一的问题是HTML代码中不存在这种可能性。我必须右键单击odd并单击inspect元素 问题是我必须用C来完成。 这是密码 WebBrowser webBrowser1 = new WebBrowser(); webBrowser1.Navigate("https://www.winamax.fr/paris-sportifs#/live"); StringBuilder sb2 = new StringBuilder(); foreach

我需要在winamax live博彩页面上获取赔率。唯一的问题是HTML代码中不存在这种可能性。我必须右键单击odd并单击inspect元素

问题是我必须用C来完成。 这是密码

WebBrowser webBrowser1 = new WebBrowser();
webBrowser1.Navigate("https://www.winamax.fr/paris-sportifs#/live");
StringBuilder sb2 = new StringBuilder();
foreach (HtmlElement elm in webBrowser1.Document.All)
    if (elm.GetAttribute("className") == "contestant-name")
        sb2.Append(elm.InnerHtml);
HtmlDocument doc = webBrowser1.Document;
doc.Body.InnerHtml = sb2.ToString();
当我编译它时,它向我显示webBrowser1.Document为null。没有这样的限制


有人知道为什么webBrowser1.Document为空吗?

所以如果我理解,我必须在我的EventHandler中放入一个函数。 但是我必须在EventHandler之前或在EventHandler中启动导航吗

我尝试了这一点,但事件处理程序中需要一个方法名。我真的不知道该怎么办

public static void wina()
{            

    WebBrowser webBrowser1 = new WebBrowser();
    webBrowser1.Navigate("https://www.winamax.fr/paris-sportifs#/live");
    webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(recup(webBrowser1));


}

public static void tryrecup(WebBrowser e)
{

    StringBuilder sb2 = new StringBuilder();
    foreach (HtmlElement elm in e.Document.All)
        if (elm.GetAttribute("className") == "contestant-name")
            sb2.Append(elm.InnerHtml);
    HtmlDocument doc = e.Document;
    doc.Body.InnerHtml = sb2.ToString();
}
退房