首页 新闻 会员 周边

HttpClient模拟登录百度

0
悬赏园豆:5 [已解决问题] 解决于 2015-02-10 21:13
   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的数据

登录却反回空字符串,初学这个不知道哪里出错了,我的分也不多了,希望大侠指导

 

图片不大看的清除,我截取了密码的后部分。再传一张

大芝麻的主页 大芝麻 | 初学一级 | 园豆:4
提问于:2015-02-06 19:27
< >
分享
最佳答案
0

你的token肯定失效了。

收获园豆:5
上帝之城 | 老鸟四级 |园豆:2549 | 2015-02-06 19:50

请问这个应该怎么处理。。新手球指教

大芝麻 | 园豆:4 (初学一级) | 2015-02-06 20:02

@大芝麻: 根据经验,第一次请求,获取token,第二次用账号密码连同第一次获取的token登录。

上帝之城 | 园豆:2549 (老鸟四级) | 2015-02-06 20:15

@上帝之城: 谢谢 我试试

大芝麻 | 园豆:4 (初学一级) | 2015-02-06 20:53

@上帝之城: - -找半天不知道怎么通过HttpClient获取tocken.请打下指教

大芝麻 | 园豆:4 (初学一级) | 2015-02-06 21:58

@大芝麻: 跟踪一下浏览器,看是什么时候产生的

上帝之城 | 园豆:2549 (老鸟四级) | 2015-02-06 22:13
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册