Button click in web browser

后端 未结 2 1792
深忆病人
深忆病人 2021-01-14 09:22

I have created web browser, now i want to by clicking button1 on my form click the button on the web.

private void button1_Click(object sender, EventArgs e)
         


        
2条回答
  •  孤街浪徒
    2021-01-14 10:17

    The website doesn't prevent POSTing a form to it. So you could always just create your own webpage with the form that points to it.

    HTML

    
    

    c#

    private void button1_Click(object sender, EventArgs e)
    {
        webBrowser1.DocumentText = "[The HTML from above here]";
        webBrowser1.Document.GetElementById("domain").SetAttribute("value", IP.Text);
        webBrowser1.Document.GetElementById("submit").InvokeMember("click");
    }
    

    If you are planning on scraping the WHOIS information. You must ensure it's not against the terms and conditions to do so. Most WHOIS services don't allow automated checks.

    If they do and that's what you are trying to do then you should consider using HttpWebRequest instead, it's much more efficient. See an example here on how to use http://swhobby.blogspot.co.uk/2010/03/c-example-of-http-post.html

提交回复
热议问题