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

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

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

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

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

查看: 14537|回复: 3

[求助] 怎么找到正确的post数据?post用户名密码总是出错。

[复制链接]
发表于 2014-1-7 20:32:19 | 显示全部楼层 |阅读模式
怎么找到正确的post数据?从没接触过抓包,汗!    post用户名密码总是出错,望大大指点下我这个新手吧。想抓取单位内网联网核查系统的处理结果,需要先登陆。网址:http://202.168.1.149/picp
先附上该网页的html:

[HTML] 纯文本查看 复制代码
<form action="SecurityAction.do?method=login" method="post">
<table width="1001" border="0" cellpadding="0" cellspacing="0">
  <tr><td height="70" background="/picp/image/logo.jpg;jsessionid=0000fDRExPhFiM1FkENuRi-cbTN:16pltg75b"></td>
  </tr><tr><td height="30" background="/picp/image/menu_bar.jpg;jsessionid=0000fDRExPhFiM1FkENuRi-cbTN:16pltg75b">  <span class="STYLE2">欢迎进入联网核查公民身份信息系统,请登录。</span></td>
  </tr><tr><td height="467" background="/picp/image/log.jpg;jsessionid=0000fDRExPhFiM1FkENuRi-cbTN:16pltg75b"><div id="Layer1">
      <input name="piUsersDto.usercode" type="text" class="log" maxlength="10"/><br /><br />
      <input AUTOCOMPLETE="off" name="piUsersDto.password" type="password" class="log"  maxlength="8"/>
      <input type="submit" name="Submit" value="" style="width:1px;height:1px"></div>
    <div id="Layer2"><img src="/picp/image/logbutton.jpg;jsessionid=0000fDRExPhFiM1FkENuRi-cbTN:16pltg75b" width="95" height="52" border="0"/></div></td></tr>
</table>
</form>


正常能登陆用户名:G1151002    密码:147258

照着站长的httphelper画了个登陆代码:
[C#] 纯文本查看 复制代码
            string postdata = this.textbox1.Text;
            MessageBox.Show(postdata);
            HttpHelper http = new HttpHelper();
            HttpItem item = new HttpItem()
            {
                URL = "http://202.168.1.149/picp/",//URL这里都是测试     必需项
                Encoding = null,//编码格式(utf-8,gb2312,gbk)     可选项 默认类会自动识别
                //Encoding = Encoding.Default,
                Method = "get",//URL     可选项 默认为Get
            };
            //得到HTML代码
            HttpResult result = http.GetHtml(item);
            MessageBox.Show(result.Html);


item = new HttpItem()
            {
                URL = "http://202.168.1.149/picp/SecurityAction.do?method=login",//URL     必需项    
                Method = "post",//URL     可选项 默认为Get   
                IsToLower = false,//得到的HTML代码是否转成小写     可选项默认转小写   
                Cookie = result.Cookie,//字符串Cookie     可选项   
                Referer = "",//来源URL     可选项   
                Postdata = postdata,//Post数据     可选项GET时不需要写   
                Timeout = 100000,//连接超时时间     可选项默认为100000    
                ReadWriteTimeout = 30000,//写入Post数据超时时间     可选项默认为30000   
                UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",//用户的浏览器类型,版本,操作系统     可选项有默认值   
                ContentType = "text/html",//返回类型    可选项有默认值   
                Allowautoredirect = false,//是否根据301跳转     可选项   
                //CerPath = "d:\123.cer",//证书绝对路径     可选项不需要证书时可以不写这个参数   
                //Connectionlimit = 1024,//最大连接数     可选项 默认为1024    
                ProxyIp = "",//代理服务器ID     可选项 不需要代理 时可以不设置这三个参数    
                //ProxyPwd = "123456",//代理服务器密码     可选项    
                //ProxyUserName = "administrator",//代理服务器账户名     可选项   
            };
            //得到新的HTML代码
            result = http.GetHtml(item);
            MessageBox.Show(result.Html);


postdata设置的是:piUsersDto.usercode=G1151002&piUsersDto.password=147258

运行后得到的html页面显示用户不存在,(正常应该是 欢迎xxx登陆)求大大看看是post的数据不对还是什么其它问题?

附上ieHTTPHeaders弄到的东东(这算不算抓包?实在是没接触过这些,望指点)


[C#] 纯文本查看 复制代码
HTTP/1.1 200 OK
Date: Tue, 07 Jan 2014 07:16:08 GMT
Server: IBM_HTTP_Server
Last-Modified: Wed, 08 Aug 2012 07:28:16 GMT
Content-Length: 15193
Keep-Alive: timeout=10
Connection: Keep-Alive
Content-Type: image/jpeg
Content-Language: zh-CN
Set-Cookie: BIGipServerpool_lwhc=434809024.20480.0000; expires=Wed, 08-Jan-2014 04:51:44 GMT; path=/

POST /picp/SecurityAction.do?method=login HTTP/1.1
Accept: image/pjpeg, image/jpeg, image/x-xbitmap, image/gif, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer: http://202.168.1.149/picp/
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)
Host: 202.168.1.149
Content-Length: 55
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: BIGipServerpool_lwhc=434809024.20480.0000; JSESSIONID=0000XdbjOirbPxUs2Ie_27gVsxq:16pltg2gr

piUsersDto.usercode=G1151002&piUsersDto.password=1472584

HTTP/1.1 200 OK
Date: Tue, 07 Jan 2014 07:16:42 GMT
Server: IBM_HTTP_Server
Keep-Alive: timeout=10
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=GBK
Content-Language: zh-CN





1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2014-1-8 08:15:34 | 显示全部楼层
把你第二步的
[C#] 纯文本查看 复制代码
 ContentType = "text/html",//返回类型    可选项有默认值 
  换成
[C#] 纯文本查看 复制代码
 ContentType = "application/x-www-form-urlencoded",//返回类型   
可选项有默认值   
这样试试
另外你的网站打不开没办法帮你测试
 楼主| 发表于 2014-1-8 23:40:25 | 显示全部楼层
谢谢老大,下午试了下,果然是这个的问题。顺带问下,是不是表单默认是ContentType = "application/x-www-form-urlencoded",而"text/html"只用于头文件?
发表于 2014-1-9 08:10:46 | 显示全部楼层
mr.two 发表于 2014-1-8 23:40
谢谢老大,下午试了下,果然是这个的问题。顺带问下,是不是表单默认是ContentType = "application/x-www-f ...

不一定这个你看抓到的包信息吧,包里面都有显示
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

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

GMT+8, 2024-5-17 08:57

© 2014-2021

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