- try
- {
- string uriString = "表单地址";
- WebClient myWebClient = new WebClient();
- string postData = "subject=aaaaa&message=bbbbbbb&formhash=91e2aabd";
- myWebClient.Headers.Add("Content-Type","application/x-www-form-urlencoded");
- myWebClient.Headers.Add("Cookie","cdb_sid=nNvaG8; cdb_cookietime=2592000;cdb_auth=UVMEAVcABlpWVQZVUwxTVQwFXAoMVAgEUQMKUQUFAgtqawc;");
- byte[] byteArray = System.Text.Encoding.ASCII.GetBytes(postData);;
- byte[] responseArray = myWebClient.UploadData(uriString,"POST",byteArray);
- string resp = System.Text.Encoding.GetEncoding("gb2312").GetString(responseArray);
- textBox1.Text = resp;
- }
- catch(Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
用C#向表单提交数据并且得到返回页面代码
最新推荐文章于 2024-08-31 16:57:07 发布