程序post

            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); 
posted @ 2008-12-08 15:16  烈马狂生  阅读(477)  评论(1编辑  收藏  举报