简体   繁体   中英

How to WebBrowser post on my facebook wall?

How to WebBrowser post on my wall?

I am using this code, he gets to play text in the textarea but not post.

            HtmlElement ele = webBrowser1.Document.GetElementById("xhpc_message");
        if (ele != null)
            ele.InnerText = "Hello Word";



        ele = webBrowser1.Document.GetElementById("Post");
        if (ele != null)
            ele.InvokeMember("click");

Do I need to spend some more parameter?

Try this, assuming that the field, "xhpc_message" is where you want to post your message:

    Dim inp As HtmlElement
    For Each inp In WebBrowser1.Document.GetElementsByTagName("textarea")
    If inp.GetAttribute("name") = "xhpc_message" Then
    inp.SetAttribute("value", "your text")
    End If
    Next

You will then need to figure out what the name of the submit button is to post the form.

HtmlElement timelineContainer = null;

...

timelineContainer = webBrowser1.Document.GetElementById("timeline_react_composer_container");  
HtmlElement div1 = timelineContainer.FirstChild;

foreach (HtmlElement txtArea in div1.GetElementsByTagName("textarea"))
{
    if(txtArea.GetAttribute("name") == "xhpc_message_text")
    {
        txtArea.SetAttribute("value", "Test V2 \r\n http .. ");
        txtArea.Focus();
    }
}

...

HtmlElement btn = timelineContainer.GetElementsByTagName("button")[0];
btn.InvokeMember("click");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM