使用 Webbrowser 控件获取和 post 数据?
Use Webbrowser control to get and post data?
我有一个带有网络浏览器控件的 windows 表单。使用此控件,我需要登录一个网站,并获取 post 数据。
登录部分将保留手动,因为各种 headers 和 cookie 以及创建和存储。
但是,是否可以使用控件发送 post/get 请求?
我做了这样的事情,它对我有用。
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");
希望对您有所帮助
我有一个带有网络浏览器控件的 windows 表单。使用此控件,我需要登录一个网站,并获取 post 数据。
登录部分将保留手动,因为各种 headers 和 cookie 以及创建和存储。
但是,是否可以使用控件发送 post/get 请求?
我做了这样的事情,它对我有用。
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");
希望对您有所帮助