问题
I have a windows form with a webbrowser control. Using this control, I need login to a website, and get and post data.
The login part will remain manually because various headers and cookies and created and stored.
However, is it possible to use the control to send post/get requests?
回答1:
I do something like this and it works for me.
string postData = "value1=" + 1 + "&value2=" + 2 + "&value3=" + 3;
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
byte[] bytes = encoding.GetBytes(postData);
string url = "http://www.domain.com/addSomething";
webBrowser1.Navigate(url, string.Empty, bytes, "Content-Type: application/x-www-form-urlencoded");
I hope it is of help.
来源:https://stackoverflow.com/questions/32837084/use-webbrowser-control-to-get-and-post-data