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

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

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

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

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

查看: 2601|回复: 3

[其他] 求帮忙,我无法得到返回的值

[复制链接]
发表于 2013-12-14 16:19:00 | 显示全部楼层 |阅读模式
本帖最后由 努力学习 于 2013-12-14 16:25 编辑

连接为: https://secure.square-enix.com/a ... 6e45b8ee95a899d67ba
作用是验证输入信息后是返回的提示。
我先get这个页面的值,里面有几个hidden的值,我先得到。
再输入用户名和密码进行post。
然后就返回一个页面,再对那个页面进行跳转,最后得到的页面就是我最开始打开的页面。
代码如下:
[C#] 纯文本查看 复制代码
        HttpHelper httpHelper = new HttpHelper();
            HttpItem httpItem = new HttpItem();
            HttpResult httpResult = null;

            ////先空的访问一次,然后再进行获取值后再访问
            httpItem.Method = "GET";
            httpItem.URL = "https://secure.square-enix.com/account/app/svc/register2?id=15d38cf138a556e45b8ee95a899d67ba";
            httpResult = httpHelper.GetHtml(httpItem);
            //得到这个里面的隐藏的信息
            // Console.WriteLine(httpResult.Html);
            string strreg1 = "name=\"_seq\" value=\"(.*)\" />";
            string strreg2 = "name=\"_url\" value=\"(.*)\" />";
            string strreg3 = "name=\"_event\" value=\"(.*)\" />";
            string strreg4 = "name=\"_st_regDat3\" value=\"(.*)\" />";
            string strreg5 = "name=\"_st_birthday\" value=\"(.*)\" />";
            string strreg6 = "name=\"_st_redirectInfo\" value=\"(.*)\" />";
            string strreg7 = "name=\"_st_rWallet\" value=\"(.*)\" />";
            string strreg8 = "name=\"_st_dupSqexid\" value=\"(.*)\" />";


            string str_seq = Regex.Match(httpResult.Html, strreg1).Groups[1].Value;

            string str_url = Regex.Match(httpResult.Html, strreg2).Groups[1].Value;

            string str_event = Regex.Match(httpResult.Html, strreg3).Groups[1].Value;

            string str_st_regDat3 = Regex.Match(httpResult.Html, strreg4).Groups[1].Value;

            string str_st_birthday = Regex.Match(httpResult.Html, strreg5).Groups[1].Value;

            string str_st_redirectInfo = Regex.Match(httpResult.Html, strreg6).Groups[1].Value;

            string str_st_rWallet = Regex.Match(httpResult.Html, strreg7).Groups[1].Value;

            string str_st_dupSqexid = Regex.Match(httpResult.Html, strreg8).Groups[1].Value;
            string cookie;
            if(httpResult.CookieCollection ==null)
            {
cookie = httpResult.Cookie;
            }
            else
            {

            StringBuilder my_cookie = new StringBuilder();
             
            foreach (Cookie c in httpResult.CookieCollection)
            {
                my_cookie.Append(c.Name + "=" + c.Value + ";");
            }

            cookie = my_cookie.ToString();
            }


            httpItem = new HttpItem();
            httpItem.KeepAlive = true;
            Console.WriteLine("the hidden value is {0},{1},{2},{3},{4},{5},{6},{7} ", str_seq, str_url, str_event, str_st_regDat3, str_st_birthday, str_st_redirectInfo, str_st_rWallet, str_st_dupSqexid);
            //httpItem.CookieCollection = httpResult.CookieCollection;
            // httpItem.CookieCollection = httpResult.CookieCollection;
            //   httpItem.CookieCollection.Add(new    Cookie("cis_sessid","738feff7ee45b16722ae307ee1cac3aa169fae012a46704d22e50e7f"));
            //     httpItem.CookieCollection.Add(new  Cookie("_cf", "0"));
            

            //httpItem.ResultCookieType = ResultCookieType.CookieCollection;
            //httpItem.CookieCollection = httpResult.CookieCollection;
            //httpItem.Cookie = httpResult.Cookie;
            httpItem.Cookie = cookie;
            httpItem.Encoding = Encoding.UTF8;
            httpItem.Header.Add("Accept-encoding", "gzip, deflate");[url=https://secure.square-enix.com/account/app/svc/register2?id=15d38cf138a556e45b8ee95a899d67ba]https://secure.square-enix.com/a ... 6e45b8ee95a899d67ba[/url]
           // httpItem.Referer = "https://secure.square-enix.com/account/app/svc/register2?id=15d38cf138a556e45b8ee95a899d67ba";
            httpItem.Method = "POST";
            httpItem.URL = "https://secure.square-enix.com/account/app";
            // httpItem.Cookie = "cis_sessid=738feff7ee45b16722ae307ee1cac3aa169fae012a46704d22e50e7f;_cf=0";
            httpItem.UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0";
            httpItem.Host = "secure.square-enix.com";
            httpItem.Postdata = "_seq=" + str_seq + "&_url=" + str_url + "&_event=Submit&_st_regDat3=" + str_st_regDat3 + "&_st_birthday=" + str_st_birthday + "&_st_redirectInfo=" + str_st_redirectInfo + "&_st_rWallet=" + str_st_rWallet + "&_st_dupSqexid=" + str_st_dupSqexid + "&_pr_regDat1_contry=JP&_pr_regDat1_sqexid=av&_pr_regDat1_sqexPw=11111111111111&_pr_regDat1_sqexPwConf=11111111111111&_pr_regDat1_birthYear=0&_pr_regDat1_birthMonth=0&_pr_regDat1_birthDay=0&_pr_regDat2_hash=";
            httpItem.Cookie = cookie;
            Console.WriteLine(httpItem.Postdata);

            httpResult = httpHelper.GetHtml(httpItem);
 Console.WriteLine(httpResult.Html.ToString());
 //httpItem.Referer = "";
 httpItem.Cookie = cookie;
            httpItem.URL = "https://secure.square-enix.com/account/app/svc/Login?cont=account";
            httpItem.Postdata = "_c=1";
            httpResult = httpHelper.GetHtml(httpItem);
            //  if(httpResult.Html.IndexOf("error1")>0)
            Console.WriteLine(httpResult.Html.ToString());



1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2013-12-14 16:23:44 | 显示全部楼层
你有没有看是那一步开始不正常的,我看你把httpResult.CookieCollection转成了字符串,不需要转的,直接可以使用httpItem.CookieCollection= result.CookieCollection;这样就行了
 楼主| 发表于 2013-12-14 16:53:55 | 显示全部楼层
站长苏飞 发表于 2013-12-14 16:23
你有没有看是那一步开始不正常的,我看你把httpResult.CookieCollection转成了字符串,不需要转的,直接可 ...

我用firefox的httpfox,看了。打开这个页面之后只得到2个cookie。但是用cookie只有1个。用cookiecontainer看又为空
发表于 2013-12-16 08:03:05 | 显示全部楼层
ResultCookieType = ResultCookieType.CookieCollection,你设置这个了吗?http://www.sufeinet.com/thread-6015-1-1.html
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

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

GMT+8, 2024-5-29 11:23

© 2014-2021

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