get post
get post
DailyDiary 发表于8个月前
get post
  • 发表于 8个月前
  • 阅读 3
  • 收藏 0
  • 点赞 0
  • 评论 0

腾讯云 新注册用户 域名抢购1元起>>>   

get

  //GET 
            string url = "url";
            try
            {
                HttpWebRequest Req = (HttpWebRequest)WebRequest.Create(url);
                Req.CookieContainer = cookie;
                Req.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
                Req.Accept = "*/*";
             Req.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36 SE 2.X MetaSr 1.0";
                Req.Method = "GET";

                HttpWebResponse res = (HttpWebResponse)Req.GetResponse();
                Stream stream = res.GetResponseStream();
                StreamReader sr = new StreamReader(stream, Encoding.GetEncoding("GB2312"));
                string strResult = sr.ReadToEnd();
                
                __VIEWSTATE = "";

 

//POST

ttpWebRequest Req = null;
            HttpWebResponse Res = null;
            string url = "url";
            try
            {
                Req = (HttpWebRequest)WebRequest.Create(url);
                Req.CookieContainer = cookie;
                Req.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
                Req.Referer = "refer";
                Req.Accept = "*/*";
                Req.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36 SE 2.X MetaSr 1.0";
                Req.Method = "POST";
                Req.AllowAutoRedirect = true;

string strPOST =

"__VIEWSTATE=%2FwEPDwUKMTExOTM4OTA4OGRkahJa4sL9gWLcydx9DZkzEk0ABr0%3D&__VIEWSTATEGENERATOR=FBE090BD&__EVENTVALIDATION=%2FwEdAAl0D4J9xNWB%2BgcnFKWvnZoN4%2FQfLsHQGYVYSXJhGOfKYCKgvRijP5cR7wp7WnFU4dtC8mj0x2qcszeBnohw4I4n65iJzCLHkVO2kGDkjn3iKMyQ43FRB5dc45mq3hyL0EOtZ2K%2B50k8QAti%2BLvHoyZfkO876gXACs%2B2TTFGifuAvAs3xkef%2Fs4NIkhXFYD8aPQC3LKKA9YWz0%2FqkDJOQl0%2B1GMPZw%3D%3D&ctl00%24ContentPlaceHolder1%24hideNeedValidateCode=True&mobilePhone=&emailAddress="+ this.txtU.Text.Trim() + "&userPassword=asdasd12bb3&rePassword=asdasd12bb3&verifyCode="
                    + this.txtCode.Text.Trim() + "&ctl00%24ContentPlaceHolder1%24reg_btnSubmit=%CF%C2%D2%BB%B2%BD%A3%AC%D1%E9%D6%A4&hidEmail="
                    + this.txtU.Text.Trim() + "&hidAction=0&hidPhone=&ctl00%24ContentPlaceHolder1%24hidEmailRetcode=2&ctl00%24ContentPlaceHolder1%24hidEmailValue="
                    + this.txtU.Text.Trim() + "&hidCode=&ctl00%24ContentPlaceHolder1%24hidCheckMobileRetcode=0&ctl00%24ContentPlaceHolder1%24hidMobilePhone=0&ctl00%24ContentPlaceHolder1%24hidVerifyCode=0&ctl00%24ContentPlaceHolder1%24hidImgCodeDatahash=k3Y4QkdW1491533255006";
byte[] btys = Encoding.UTF8.GetBytes(strPOST);

Stream stream = Req.GetRequestStream();
stream.Write(btys, 0, btys.Length);
stream.Flush();
Res = (HttpWebResponse)Req.GetResponse();
Stream responseStream = Res.GetResponseStream();

//将网页获取的流读成string
StreamReader sr = new StreamReader(responseStream, Encoding.GetEncoding("GB2312"));
string strResult = sr.ReadToEnd();
this.TXTmsg.Text = (strResult);

共有 人打赏支持
粉丝 0
博文 17
码字总数 4127
×
DailyDiary
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: