有用Qt模拟post发送账户密码实现登陆的么?

zheguzai000 2013-04-14 04:29:06
这两天突然对这个感兴趣,找了个网站,首先用用浏览器打开网页输入账户密码,提交的时候用HttpAnalyze软件将post的信息抓下来

我登陆的网站是www.easyhits4u.com

获取到的post的信息如下:

POST /account.cgi HTTP/1.1
Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*
Referer: http://www.easyhits4u.com/
Accept-Language: zh-cn
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET4.0C; .NET4.0E)
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip,deflate
Host: www.easyhits4u.com
Connection: Keep-Alive
Cache-Control: no-cache
Content-Length: 87

f=logon&manual=1&fb_id=&fb_token=&google_code=&username=joke&password=qazwsxedc&x=7&y=5


做了一个按钮,按钮中实现的内容如下:



//这里是构造要发送的数据
QByteArray postData;
postData.append("f=logon&manual=1&fb_id=&fb_token=&username=");
postData.append(ui->lineEdit_user->text());
postData.append("&password=");
postData.append(ui->lineEdit_Passwd->text());
postData.append("&x=7&y=5");


request = new QNetworkRequest(QUrl("http://www.easyhits4u.com/account.cgi"));

//request->setUrl(param);
//request->setHeader();
request->setUrl(QUrl("http://www.easyhits4u.com/account.cgi"));
request->setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");
request->setRawHeader("Accept","image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*");
request->setRawHeader("Referer","http://www.easyhits4u.com");
request->setRawHeader("Accept-Language","zh-cn");
request->setRawHeader("User-Agent","Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET4.0C; .NET4.0E)");
request->setRawHeader("Content-Type","application/x-www-form-urlencoded");
request->setRawHeader("Accept-Encoding","gzip,deflate");
request->setRawHeader("Content-Length","94");
request->setRawHeader("Connection","Keep-Alive");
request->setRawHeader("Cache-Control","no-cache");

reply = netWorkAcessM->post(*request,postData);
connect(reply,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(replyErrprSlot()));



点击按钮的时候我也用HttpAnalyze工具看了,没有问题的,可就是登陆不了,而且Post完毕后,也读取不到数据。

我把那个网站的首页保存下来,把没用的删掉,就剩下登陆框,输入账户密码也是可以登陆的。

保存下来修改过的网页内容

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#" xml:lang="en" lang="en" style="height: 100%; "><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>EasyHits4U.com - Your Traffic Exchange, 1:1 Exchange Ratio, Manual Surfing, Innovative Referral Program. FREE Traffic!</title>
</head>

<body style="position: relative; min-height: 100%; top: 0px; ">

<table cellpadding="0" cellspacing="0" border="0" valign="top" width="19%">
<tbody><tr>
<td width="235" valign="top" class="left_column">

<form action="http://www.easyhits4u.com/account.cgi" method="post">
<input type="hidden" name="f" value="logon">
<input type="hidden" name="manual" value="1">
<input type="hidden" name="fb_id" value="">
<input type="hidden" name="fb_token" value="">
<!-- <input type="hidden" name="google_code" value=""> -->
<div style="width:175px; padding-left:16px; padding-right:0px; font-size:11px; padding-top:8px; ">Username or Email:<br>
<input type="text" name="username" size="30" class="login" value="" style="border: 1px solid rgb(109, 191, 109); "><br>

Password:<br>
<input type="password" name="password" class="login" value="" style="border: 1px solid rgb(109, 191, 109); "><br>
<div align="center">
<input type="image" src="./EasyHits4U.com - Your Traffic Exchange, 1 1 Exchange Ratio, Manual Surfing, Innovative Referral Program. FREE Traffic!_files/enter_btn.jpg" id="enter_btn" alt="Enter" title="Enter">

<div id="fb-root"></div>
</div>



</div></form></td>

</tr>
</tbody></table>




用webview调用我修改过的网页也是可以正常登陆的,但是自己模拟的post就是不行,大家看看我哪里出错了,有弄过的说过下

而且我发现post的信息中后面的x,y的数据每次都是不一样的,我在网页中也没有发现这个信息是怎么加进去的
f=logon&manual=1&fb_id=&fb_token=&google_code=&username=joke&password=qazwsxedc&x=7&y=5
我测试的时候就写死了,x7,y=5
...全文
488 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
气杀也么哥 2015-03-04
  • 打赏
  • 举报
回复
[yabao=四大四大阿什顿][/yabao]
气杀也么哥 2015-03-03
  • 打赏
  • 举报
回复
气杀也么哥 2015-03-03
  • 打赏
  • 举报
回复
楼主在吗,你的问题解决了吗?

21,491

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧