[C#] 纯文本查看 复制代码 string url="http://user.ynshangji.com/viplogin.jsp";
string postdata="postdata,beforUrl=&cookie_value=aoruide1&userpass=aoruide1234";
HttpWebRequest http = (HttpWebRequest)WebRequest.Create(url); //实例化httpwebrequest
CookieContainer cookie = new CookieContainer();
if (cookie.Count == 0)
{
http.CookieContainer = new CookieContainer();
cookie = http.CookieContainer;
}
else
{
http.CookieContainer = cookie;
}
http.Accept = "application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, */*";
http.ContentType = "application/x-www-form-urlencoded";
http.Method = "post";
StreamWriter write =new StreamWriter(http.GetRequestStream());
write.Write(postdata);
write.Flush();
HttpWebResponse re = (HttpWebResponse)http.GetResponse();
StreamReader getre = new StreamReader(re.GetResponseStream(), Encoding.GetEncoding("gb2312"));
html = getre.ReadToEnd();
Console.WriteLine(html);
Console.WriteLine(postcookie); 这是以上代码post成功了-
-------------------------------------------------------------
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "[url=http://user.ynshangji.com/viplogin.jsp]http://user.ynshangji.com/viplogin.jsp[/url]",
Method="post",
Accept = "application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, */*",
ContentType = "application/x-www-form-urlencoded",
Postdata = "beforUrl=&cookie_value=aoruide1&userpass=aoruide1234",
Allowautoredirect = true,
AutoRedirectCookie = true,
};
HttpResult request = http.GetHtml(item);
string html = request.Html;
Console.WriteLine(html);
}
这段失败上俩图片你看下[attach]4885[/attach][attach]4886[/attach]
|