http://www.sufeinet.com/plugin.php?id=keke_group

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程

HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成

HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子

查看: 8298|回复: 11

[其他] httphelper无法登录百度,求帮助。谢谢。

[复制链接]
发表于 2013-2-22 10:52:44 | 显示全部楼层 |阅读模式
  1. item.URL = "https://passport.baidu.com/v2/api/?login";
  2.                     item.Method = "POST";
  3.                     item.Postdata = "ppui_logintime=235281&charset=utf-8&codestring=&token=871f97a97cd6ec29cb62761d38d75343&isPhone=false&index=0&u=&safeflg=0&staticpage=http%3A%2F%2Fwww.baidu.com%2Fcache%2Fuser%2Fhtml%2Fjump.html&loginType=1&tpl=mn&callback=parent.bdPass.api.login._postCallback&username=XXXXXX&password=YYYYYY&verifycode=&mem_pass=on";
  4.                     item.Referer = "http://www.baidu.com/cache/user/html/login-1.2.html";
  5.                     item.Encoding = "utf-8";
  6.                     item.ContentType = "application/x-www-form-urlencoded";
  7.                     item.UserAgent = "Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0";
  8.                     item.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
  9.                     item.Allowautoredirect = true;

  10.                     HttpResult result_login = http.GetHtml(item);
复制代码
XXXXXX  处是帐号
YYYYYY 处是密码
弄了很久一直不行。
谢谢了。



1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2013-2-22 11:31:00 | 显示全部楼层

回帖奖励 +1 金钱

百度的登录还有后续的操作,你看看他返回的是什么,然后分析一下就明白了
 楼主| 发表于 2013-2-22 11:42:48 | 显示全部楼层
admin 发表于 2013-2-22 11:31
百度的登录还有后续的操作,你看看他返回的是什么,然后分析一下就明白了

后续的操作指的是哪些,比如。。。。

怎么分析百度返回的东西,我用的是fiddler。

谢谢回复~
发表于 2013-2-22 11:51:35 | 显示全部楼层
HttpResult result_login = http.GetHtml(item); 你看看这里返加的什么数据,
看一下返回的HTML代码 也许是使用JS跳转的
 楼主| 发表于 2013-2-25 22:08:15 | 显示全部楼层
admin 发表于 2013-2-22 11:51
HttpResult result_login = http.GetHtml(item); 你看看这里返加的什么数据,
看一下返回的HTML代码 也许是 ...
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=utf-8">
  5. </head>
  6. <body>


  7. <script type="text/javascript">

  8. var url = encodeuri('http://www.baidu.com/cache/user/html/jump.html?error=119998
  9. &callback=parent.bdpass.api.login._postcallback&index=0&username=&phonenumber=&m
  10. ail=&tpl=mn&u=https%3a%2f%2fpassport.baidu.com%2f&needtomodifypassword=0&gotourl
  11. =');
  12. //parent.callback(url)
  13. window.location.replace(url);

  14. </script>
  15. </body>
  16. </html>
复制代码
得到的是这样的代码。 搞不懂是什么意思。帮我分析下。谢谢。
发表于 2013-2-26 10:01:40 | 显示全部楼层
xiaotianbao 发表于 2013-2-25 22:08
得到的是这样的代码。 搞不懂是什么意思。帮我分析下。谢谢。

重定向到这里了http://www.baidu.com/cache/user/html/jump.html?error=119998
&callback=parent.bdpass.api.login._postcallback&index=0&username=&phonenumber=&m
ail=&tpl=mn&u=https%3a%2f%2fpassport.baidu.com%2f&needtomodifypassword=0&gotourl
=,你直接请求这个地址试试当然里面的参数要相应的修改下,比如用户名和密码
 楼主| 发表于 2013-2-26 12:11:48 | 显示全部楼层
admin 发表于 2013-2-26 10:01
重定向到这里了http://www.baidu.com/cache/user/html/jump.html?error=119998
&callback=parent.bdpass ...
  1. http://www.baidu.com/cache/user/html/jump.html?error=119998
  2. &callback=parent.bdpass.api.login._postcallback&index=0&username=XXXX&phonenumber=&m
  3. ail=&tpl=mn&u=https%3a%2f%2fpassport.baidu.com%2f&needtomodifypassword=YYYY&gotourl
  4. =
复制代码
用户名好像有参数username
密码好像没有参数。。。我把密码填在needtomodifypassword后面
就是上面的xxxx和yyyy
然后我在浏览器里访问后没反应。
发表于 2013-2-26 12:57:07 | 显示全部楼层
xiaotianbao 发表于 2013-2-26 12:11
用户名好像有参数username
密码好像没有参数。。。我把密码填在needtomodifypassword后面
就是上面的xx ...

我晕,你直接访问怎么可能会有效果呢?最少也得带上Cookie吧,怎么说了是百度,做的也不能太次了,呵呵
 楼主| 发表于 2013-2-26 14:29:56 | 显示全部楼层
admin 发表于 2013-2-26 12:57
我晕,你直接访问怎么可能会有效果呢?最少也得带上Cookie吧,怎么说了是百度,做的也不能太次了,呵呵
  1. <!doctype html>
  2. <html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /
  3. ></head><body><script type="text/javascript">
  4. (function(){
  5.         var querystr = location.search.substring(1).split('&')
  6.         ,onequerystr
  7.         ,callbackstr
  8.         ,config = {};
  9.         for(var i in querystr){
  10.         onequerystr = querystr[i].split('=');
  11.                 if(!callbackstr && onequerystr[0] == 'callback'){
  12.                         callbackstr = onequerystr[1];
  13.                 };
  14.                 config[onequerystr[0]] = onequerystr[1];
  15.     }
  16.         parent.bdpass.api[callbackstr](config);
  17. })();
  18. </script>
  19. </body></html>
复制代码
我用先前得到的cookie和带了用户名和密码的URL,以GET形式,得到result.html是这样的。
这说什么什么呢,接下来又应该怎么做。
 楼主| 发表于 2013-2-27 16:10:29 | 显示全部楼层
admin 发表于 2013-2-26 12:57
我晕,你直接访问怎么可能会有效果呢?最少也得带上Cookie吧,怎么说了是百度,做的也不能太次了,呵呵

我感觉是那个postdata里的token的问题,这个token值怎么取呢?
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

QQ|手机版|小黑屋|手机版|联系我们|关于我们|广告合作|苏飞论坛 ( 豫ICP备18043678号-2)

GMT+8, 2024-3-28 16:23

© 2014-2021

快速回复 返回顶部 返回列表