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

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

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

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

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

查看: 3548|回复: 8

[咨询站长] 麻烦帮我看看,为什么post后状态还是登陆失败 已付上代码

[复制链接]
发表于 2017-6-27 19:57:23 | 显示全部楼层 |阅读模式
[C#] 纯文本查看 复制代码
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
    URL = "https://account.ankama.com/sso",//URL     必需项
    Method = "POST",//URL     可选项 默认为Get
    Timeout = 100000,//连接超时时间     可选项默认为100000
    ReadWriteTimeout = 30000,//写入Post数据超时时间     可选项默认为30000
    UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0",//用户的浏览器类型,版本,操作系统     可选项有默认值
    Accept = "text/html, application/xhtml+xml, */*",//    可选项有默认值
    ContentType = "application/x-www-form-urlencoded",//返回类型    可选项有默认值
    Referer = "https://secure.dofus.com/fr/achat-bourses-kamas-ogrines/identification",//来源URL     可选项
    Allowautoredirect = true,//是否根据301跳转     可选项
    Postdata = "action=login&from=https%3A%2F%2Fsecure.dofus.com%2Ffr%2Fachat-bourses-kamas-ogrines%2Fidentification&login=fireburiead&password=Abcd1234%21",//Post数据     可选项GET时不需要写
};
HttpResult result = http.GetHtml(item);
string html = result.Html;
string cookie = result.Cookie;
richTextBox1.Text = html;



chrom 获取的数据

  • :authority:
    account.ankama.com
  • :method:
    POST
  • :path:
    /sso
  • :scheme:
    https
  • accept:
    text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
  • accept-encoding:
    gzip, deflate, br
  • accept-language:
    zh-CN,zh;q=0.8
  • cache-control:
    max-age=0
  • content-length:
    139
  • content-type:
    application/x-www-form-urlencoded
  • cookie:
    LANG=en; _ga=GA1.2.26411807.1493134954; __cfduid=dc3a06994ba534694555017ef13eaef1b1497449062; SID=289DDCCF5D03F3395DEBA60B5D100001; __cfruid=59abd3fc3c916c2d151a9824f427c466f5a8e350-1498528659; _ga=GA1.1.1618553311.1480159108; _gid=GA1.1.2100736446.1498532143
  • origin:
    https://secure.dofus.com
  • referer:
    https://secure.dofus.com/fr/achat-bourses-kamas-ogrines/identification
  • upgrade-insecure-requests:
    1
  • user-agent:
    Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36



action=login&from=https%3A%2F%2Fsecure.dofus.com%2Ffr%2Fachat-bourses-kamas-ogrines%2Fidentification&login=fireburiead&password=Abcd1234%21



1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2017-6-28 08:30:28 | 显示全部楼层
没看到有输入的账户啊,登录是需要加Cookie的,
 楼主| 发表于 2017-6-28 11:24:55 | 显示全部楼层
postdata里login=fireburiead&password=Abcd1234%21 这个就是用户名和密码

Cookie = "",
加到里面也不行
发表于 2017-6-28 11:36:53 | 显示全部楼层
[C#] 纯文本查看 复制代码
HttpHelper http = new HttpHelper();  
HttpItem item = new HttpItem()  
{  
    URL = "https://account.ankama.com/sso",//URL     必需项  
    Method = "POST",//URL     可选项 默认为Get  
    Timeout = 100000,//连接超时时间     可选项默认为100000  
    ReadWriteTimeout = 30000,//写入Post数据超时时间     可选项默认为30000  
    IsToLower = false,//得到的HTML代码是否转成小写     可选项默认转小写  
    Cookie = "",//字符串Cookie     可选项  
    UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0",//用户的浏览器类型,版本,操作系统     可选项有默认值  
    Accept = "text/html, application/xhtml+xml, */*",//    可选项有默认值  
    ContentType = "application/x-www-form-urlencoded",//返回类型    可选项有默认值  
    Referer ="https://account.ankama.com/en/login?f=https%3A%2F%2Faccount.ankama.com%2Fen%2Faccount%2Finformation",//来源URL     可选项  
    Allowautoredirect = False,//是否根据301跳转     可选项  
    AutoRedirectCookie = False,//是否自动处理Cookie     可选项  
    //CerPath = "d:\123.cer",//证书绝对路径     可选项不需要证书时可以不写这个参数  
    //Connectionlimit = 1024,//最大连接数     可选项 默认为1024  
    Postdata = "action=login&from=https://account.ankama.com/en/account/information&login=fireburiead&password=Abcd1234!",//Post数据     可选项GET时不需要写  
    //ProxyIp = "192.168.1.105:2020",//代理服务器ID     可选项 不需要代理 时可以不设置这三个参数  
    //ProxyPwd = "123456",//代理服务器密码     可选项  
    //ProxyUserName = "administrator",//代理服务器账户名     可选项  
    ResultType = ResultType.String,//返回数据类型,是Byte还是String  
};  
HttpResult result = http.GetHtml(item);  
string html = result.Html;  
string cookie = result.Cookie;  
 楼主| 发表于 2017-6-28 11:44:36 | 显示全部楼层
返回的html为空. 我把Allowautoredirect改成true后.直接转到登陆页面. 没有登陆成功
 楼主| 发表于 2017-6-28 11:48:34 | 显示全部楼层
登陆成功后  gjloyok   这个字符串会出现,这是人物的角色名
发表于 2017-6-28 12:33:38 | 显示全部楼层
登录成功后要带上Cookie去访问,
 楼主| 发表于 2017-6-28 13:16:54 | 显示全部楼层
            HttpHelper http = new HttpHelper();
            HttpItem item = item = new HttpItem()
            {
                URL = "https://account.ankama.com/sso",//URL     必需项  
                Method = "OST",//URL     可选项 默认为Get  
                Timeout = 15000,//连接超时时间     可选项默认为100000  
                ReadWriteTimeout = 15000,//写入Post数据超时时间     可选项默认为30000  
                IsToLower = false,//得到的HTML代码是否转成小写     可选项默认转小写  
                Cookie = "",//字符串Cookie     可选项  
                ResultType = ResultType.String,
                UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36",//用户的浏览器类型,版本,操作系统     可选项有默认值  
                Accept = "text/html, application/xhtml+xml, */*",//    可选项有默认值  
                ContentType = "application/x-www-form-urlencoded",//返回类型    可选项有默认值  
                Referer = "https://secure.dofus.com/fr/achat-bourses-kamas-ogrines/identification",//来源URL     可选项  
                Allowautoredirect = false,//是否根据301跳转     可选项  
                AutoRedirectCookie = true,//是否自动处理Cookie     可选项  
                Postdata = "action=login&from=https%3A%2F%2Fsecure.dofus.com%2Ffr%2Fachat-bourses-kamas-ogrines%2Fidentification&login=fireburiead&password=Abcd1234%21",//Post数据     可选项GET时不需要写  
                ProtocolVersion = System.Net.HttpVersion.Version11,//获取或设置用于请求的 HTTP 版本。默认为 System.Net.HttpVersion.Version11  
            };
            HttpResult result = http.GetHtml(item);
            string html = result.Html;
            string cookie = result.Cookie;
            if (!string.IsNullOrEmpty(cookie))
            {
                item = new HttpItem()
               {
                   URL = "https://secure.dofus.com/fr/achat-bourses-kamas-ogrines/0-francaise/achat-kamas",
                   UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36",
                   ResultType = ResultType.String,
                   Method = "GET",
                   Cookie = result.Cookie,
                   Allowautoredirect = true,
               };
                result = http.GetHtml(item);
                html = result.Html;
                cookie = result.Cookie;
                result = http.GetHtml(item);
                richTextBox1.Text = result.Html;
                MessageBox.Show(html.IndexOf("gjloyok").ToString());
            }


就是登陆不成功呀
发表于 2017-7-3 11:14:00 | 显示全部楼层
楼主加油,我们都看好你哦。
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

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

GMT+8, 2024-4-20 23:08

© 2014-2021

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