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

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

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

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

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

查看: 13092|回复: 16

[求助] Httphelper登陆HTTPS的问题

[复制链接]
发表于 2012-11-2 13:46:41 | 显示全部楼层 |阅读模式
  1. var httphelper = new FunctionServices.httphelper();
  2.             FunctionServices.HttpItem httpItem = new FunctionServices.HttpItem();
  3.             httpItem.URL = @"htt ps://w ww.kuaipa n.cn/ind ex.php?ac=account&op=login";
  4.             httpItem.Encoding = "UTF-8";
  5.             httpItem.Postdata = string.Format("isajax=yes&username={0}&userpwd={1}", UserName, Password);
  6.             httpItem.Referer = @"ht tps://www .kuaipan.cn/account_login.htm";
  7.             httpItem.Method = "POST";
  8.             httpItem.ContentType = "application/x-www-form-urlencoded";
  9.             httpItem.Cookie = httphelper.Cookie;

  10.             string html2 = httphelper.GetHtml(httpItem);
复制代码
想做一个快盘自动登陆查找文件的程序,上面的代码正常来说httpItem.URL应该返回登陆结果的JSON字符串
         
但是上面这段代码返回的是登陆页面的HTML代码,也就是登陆没成功,请问是什么原因

请问能否以这个快盘为例做个 实例呢?
论坛的登陆HTT PS ://WWW .CCKAN.NET的例子我看了,照着做了也用不了




1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
 楼主| 发表于 2012-11-2 13:47:53 | 显示全部楼层
论坛不能发连接...晕
发表于 2012-11-2 14:01:01 | 显示全部楼层
   httpItem.Cookie = httphelper.Cookie; 是从那里取的?
刚注册是不能发的,现在你应该可以发了
 楼主| 发表于 2012-11-2 14:50:50 | 显示全部楼层
  httpItem.Cookie = httphelper.Cookie; 一开始没有值 直接登陆页面POST的
晕,我已经注册了好久的了之前也发过贴的..
发表于 2012-11-2 15:01:47 | 显示全部楼层
graper 发表于 2012-11-2 14:50
httpItem.Cookie = httphelper.Cookie; 一开始没有值 直接登陆页面POST的
晕,我已经注册了好久的了之前也 ...

你应该先访问一下登录界面取到一个Cookie,然后带着这个Cookie再进行登录。应该就可以了
第一次发贴成功之后就可以了,不能发连接是可以发网址的,你现在是可以发的,广告信息比较多,请谅解
 楼主| 发表于 2012-11-2 15:08:26 | 显示全部楼层
试过先GET,但取不到COOKIE

希望管理员能用这个类做一个完整的实例给我们参考
 楼主| 发表于 2012-11-2 16:03:37 | 显示全部楼层
  1.          
  2.             string UserName = User.Name;
  3.             string Password = User.Password;

  4.             var HttpHelper=new FunctionServices.httphelper();
  5.             var objHttpItem = new FunctionServices.HttpItem();
  6.             objHttpItem.URL = "https://www.kuaipan.cn/account_login.htm";
  7.             objHttpItem.Encoding = "UTF-8";
  8.             objHttpItem.Method = "GET";
  9.             objHttpItem.Referer = "";
  10.             objHttpItem.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1";
  11.             objHttpItem.ContentType = "text/html";
  12.             objHttpItem.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";

  13.             string html1 = HttpHelper.GetHtml(objHttpItem);
  14.             ////取得登录后的Cookie
  15.             string cookie = HttpHelper.cookie;

  16.             var httpItem = new FunctionServices.HttpItem();
  17.             httpItem.URL = @"https://www.kuaipan.cn/index.php?ac=account&op=login";
  18.             httpItem.Encoding = "UTF-8";
  19.             httpItem.Postdata = string.Format("isajax=yes&username={0}&userpwd={1}", UserName, Password);
  20.             httpItem.Referer = @"https://www.kuaipan.cn/account_login.htm";
  21.             httpItem.Method = "POST";
  22.             httpItem.ContentType = "application/x-www-form-urlencoded";
  23.             //httpItem.Accept = "application/json, text/javascript, */*";
  24.             httpItem.Cookie = cookie;

  25.             string html2 = HttpHelper.GetHtml(httpItem);
  26.             ////取得登录后的Cookie
  27.             string cookie1 = HttpHelper.cookie;
复制代码
实在是不行,请指教
COOKIE是取到了的,登陆不了
 楼主| 发表于 2012-11-5 08:55:53 | 显示全部楼层
竟然没人理了.失望
发表于 2012-11-5 10:22:13 | 显示全部楼层
这个是https的,有时间吧,现在没空能他,
发表于 2012-11-16 17:17:33 | 显示全部楼层
我就是说,怎么一直不行
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

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

GMT+8, 2024-4-29 22:50

© 2014-2021

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