程序post

mac2022-06-30  22

            ASCIIEncoding encoding  =   new  ASCIIEncoding();              string  postData  =   " srh_type=0 " ;             postData  +=   " &cityid=0101 " ;             postData  +=   " &price=-1 " ;             postData  +=   " &star=-1 " ;             postData  +=   " &__EVENTTARGET=Search1$Pager " ;             postData  +=   " &__EVENTARGUMENT=1 " ;              byte [] data  =  encoding.GetBytes(postData);              //  Prepare web request             HttpWebRequest myRequest  =             (HttpWebRequest)WebRequest.Create( " http://** " );             myRequest.Method  =   " POST " ;             myRequest.ContentType  =   " application/x-www-form-urlencoded " ;             myRequest.ContentLength  =  data.Length;             Stream newStream  =  myRequest.GetRequestStream();              //  Send the data.             newStream.Write(data,  0 , data.Length);             newStream.Close();              //  Get response             HttpWebResponse myResponse  =  (HttpWebResponse)myRequest.GetResponse();             StreamReader reader  =   new  StreamReader(myResponse.GetResponseStream(), Encoding.Default);              string  content  =  reader.ReadToEnd();             Response.Write(content); 

转载于:https://www.cnblogs.com/Elong/archive/2008/12/08/1350382.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)