[C#] 纯文本查看 复制代码 string url = "http://www.renren.com/PLogin.do";
string postdata = string.Format("email={0}&icode={1}&origURL=http%3A%2F%2Fwww.renren.com%2Fhome&domain=renren.com&key_id=1&captcha_type=web_login&password=3d07522b2090e8669b15712464f644eff5cb978a8a00ab60d7bd3a8cb87870e7&rkey=d0cf42c2d3d337f9e5d14083f2d52cb2", HttpUtility.UrlEncode(textBox1.Text.Trim()), HttpUtility.UrlEncode(textBox3.Text.Trim()));
string Cookies = ""; [C#] 纯文本查看 复制代码 HttpHelper http = new HttpHelper();
[C#] 纯文本查看 复制代码 HttpItem item = new HttpItem() //登陆Post
{
URL = "http://www.renren.com/PLogin.do",
Method = "POST",
ContentType = "application/x-www-form-urlencoded",
Postdata = postdata,,
UserAgent = "Mozilla/5.0 (Windows NT 5.1; rv:25.0) Gecko/20100101 Firefox/25.0",//模拟一个UserAgent
Allowautoredirect = true,
Cookie = Cookies
};
HttpResult httpresult = http.GetHtml(item);
Cookies = httpresult.Cookie;
string WebContent = httpresult.Html;
不知道哪个地方出了问题 一直无法正常登陆
[C#] 纯文本查看 复制代码 string url = "http://www.renren.com/PLogin.do";
string postdata = string.Format("email={0}&icode={1}&origURL=http%3A%2F%2Fwww.renren.com%2Fhome&domain=renren.com&key_id=1&captcha_type=web_login&password=3d07522b2090e8669b15712464f644eff5cb978a8a00ab60d7bd3a8cb87870e7&rkey=d0cf42c2d3d337f9e5d14083f2d52cb2", HttpUtility.UrlEncode(textBox1.Text.Trim()), HttpUtility.UrlEncode(textBox3.Text.Trim()));
string Cookies = "";
byte[] data = Encoding.UTF8.GetBytes(postdata);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
//request.CookieContainer = new CookieContainer();
//request.CookieContainer.Add(curCookies);
request.Method = "POST";//数据提交方式
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
request.UserAgent = " Mozilla/5.0 (Windows NT 5.1; rv:25.0) Gecko/20100101 Firefox/25.0";//模拟一个UserAgent
request.CookieContainer = cc;
Stream newStream = request.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
request.CookieContainer = cc;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
cc.Add(response.Cookies);
Stream stream = response.GetResponseStream();
这个可以正常登陆
|