HttpClient httpClient = new HttpClient(); httpClient.MaxResponseContentBufferSize = 256000; httpClient.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/35.0"); String url = "https://passport.baidu.com/v2/?login"; HttpResponseMessage response = httpClient.GetAsync(new Uri(url)).Result; String result = response.Content.ReadAsStringAsync().Result; List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>(); paramList.Add(new KeyValuePair<string, string>("staticpage", "https://passport.baidu.com/static/passpc-account/html/v3Jump.html")); paramList.Add(new KeyValuePair<string, string>("charset", "UTF-8")); paramList.Add(new KeyValuePair<string, string>("token", "f5fe11bc54d60e6c62949a80533f8453")); paramList.Add(new KeyValuePair<string, string>("tpl", "pp")); paramList.Add(new KeyValuePair<string, string>("subpro", "")); paramList.Add(new KeyValuePair<string, string>("apiver", "v3")); paramList.Add(new KeyValuePair<string, string>("tt", "1423221194082")); paramList.Add(new KeyValuePair<string, string>("codestring", "")); paramList.Add(new KeyValuePair<string, string>("safeflg", "0")); paramList.Add(new KeyValuePair<string, string>("u", "https://passport.baidu.com/")); paramList.Add(new KeyValuePair<string, string>("isPhone", "false")); paramList.Add(new KeyValuePair<string, string>("quick_user", "0")); paramList.Add(new KeyValuePair<string, string>("logintype", "basicLogin")); paramList.Add(new KeyValuePair<string, string>("logLoginType", "pc_loginBasic")); paramList.Add(new KeyValuePair<string, string>("idc", "")); paramList.Add(new KeyValuePair<string, string>("loginmerge", "true")); paramList.Add(new KeyValuePair<string, string>("username", "zlbdzd01")); paramList.Add(new KeyValuePair<string, string>("password", "TE2gxKLWJWDrfJlohHr2fwiHgBUUwE4LNWMXadYGLr2WrtAJq6W5fASJN+EEISKVPLdvroc+kenGuHkLzOAckEFHqtozsTbAaP/9iakJFrE8VEeKQCfErw6XOVzCRFRBmnIueC223ZaXrNO4dlkyUFp6+Y5Uaagl0RfkMJS3IgU=")); paramList.Add(new KeyValuePair<string, string>("verifycode", "")); paramList.Add(new KeyValuePair<string, string>("mem_pass", "on")); paramList.Add(new KeyValuePair<string, string>("rsakey", "ZDnTpLMUDmhMVO5fzuV2wZ0QkOYJSFnK")); paramList.Add(new KeyValuePair<string, string>("crypttype", "12")); paramList.Add(new KeyValuePair<string, string>("ppui_logintime", "9577")); response = httpClient.PostAsync(new Uri(url), new FormUrlEncodedContent(paramList)).Result; result = response.Content.ReadAsStringAsync().Result; result = Encoding.GetEncoding("GBK").GetString(Encoding.Default.GetBytes(result));
下图使用HttpFox读取到的登录时所有POST的数据
登录却反回空字符串,初学这个不知道哪里出错了,我的分也不多了,希望大侠指导
图片不大看的清除,我截取了密码的后部分。再传一张
你的token肯定失效了。
请问这个应该怎么处理。。新手球指教
@大芝麻: 根据经验,第一次请求,获取token,第二次用账号密码连同第一次获取的token登录。
@上帝之城: 谢谢 我试试
@上帝之城: - -找半天不知道怎么通过HttpClient获取tocken.请打下指教
@大芝麻: 跟踪一下浏览器,看是什么时候产生的