用C#向表单提交数据并且得到返回页面代码

    技术2022-05-11  59

    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);                }    

    最新回复(0)