CookieContainer RequestCookies = new CookieContainer();
protected void Page_Load(object sender, EventArgs e)
{
string username = "zhanghao";
string pwd = "mima";
string posturl = "http://my.anjuke.com/v2/my/login";
string postdata = "loginpost=1&formhash=&history=aHR0cDovL3NoYW5naGFpLmFuanVrZS5jb20vdjIv&systemtime=1297321220&loginName=" + username + "&loginPasswd=" + pwd + "&remember=1&submit=";
getMcc(posturl, postdata);
postdata = "txtCommunity=德安大厦&radUseType=5&txtProFloor=1&txtFloorNum=2&txtAreaNum=30&txtRoomNum=1&txtHallNum=0&txtToiletNum=0&txtProPrice=50&txtHouseAge=2000&radFitment=1&radHouseOri=0&radCurrentState=1&txtUserDefine=zheshibeizhu&txtProName=zheshibiaoti&areaTplId=&commTplId=&txtExplain=<p>zheshimiaoshu</p>&radSaleType=2&hidact=save&hidBrokerID=667389&hidCommunityID=3726";
posturl = "http://my.anjuke.com/v2/user/broker/property/sale/step1";
getMcc(posturl, postdata);
}
public void getMcc(string PostUrl, string PostData)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(PostUrl);
if (!string.IsNullOrEmpty(PostData))
{
request.CookieContainer = RequestCookies;
request.AllowAutoRedirect = true;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"; Encoding encoding = System.Text.Encoding.GetEncoding("UTF-8");
byte[] data = encoding.GetBytes(PostData);
request.ContentLength = data.Length; Stream newStream = request.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream stream = response.GetResponseStream(); using (StreamReader read = new StreamReader(stream, Encoding.UTF8))
{
string strcontent = read.ReadToEnd();
}
}
我的代码如上 但是登录完成后提交发布的时候不行 怎么回事啊? 求教各位大侠!~~~~~~~
protected void Page_Load(object sender, EventArgs e)
{
string username = "zhanghao";
string pwd = "mima";
string posturl = "http://my.anjuke.com/v2/my/login";
string postdata = "loginpost=1&formhash=&history=aHR0cDovL3NoYW5naGFpLmFuanVrZS5jb20vdjIv&systemtime=1297321220&loginName=" + username + "&loginPasswd=" + pwd + "&remember=1&submit=";
getMcc(posturl, postdata);
postdata = "txtCommunity=德安大厦&radUseType=5&txtProFloor=1&txtFloorNum=2&txtAreaNum=30&txtRoomNum=1&txtHallNum=0&txtToiletNum=0&txtProPrice=50&txtHouseAge=2000&radFitment=1&radHouseOri=0&radCurrentState=1&txtUserDefine=zheshibeizhu&txtProName=zheshibiaoti&areaTplId=&commTplId=&txtExplain=<p>zheshimiaoshu</p>&radSaleType=2&hidact=save&hidBrokerID=667389&hidCommunityID=3726";
posturl = "http://my.anjuke.com/v2/user/broker/property/sale/step1";
getMcc(posturl, postdata);
}
public void getMcc(string PostUrl, string PostData)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(PostUrl);
if (!string.IsNullOrEmpty(PostData))
{
request.CookieContainer = RequestCookies;
request.AllowAutoRedirect = true;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"; Encoding encoding = System.Text.Encoding.GetEncoding("UTF-8");
byte[] data = encoding.GetBytes(PostData);
request.ContentLength = data.Length; Stream newStream = request.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream stream = response.GetResponseStream(); using (StreamReader read = new StreamReader(stream, Encoding.UTF8))
{
string strcontent = read.ReadToEnd();
}
}
我的代码如上 但是登录完成后提交发布的时候不行 怎么回事啊? 求教各位大侠!~~~~~~~
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货