首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

怎么用vb开发一个发送http包的软件

2012-02-08 
如何用vb开发一个发送http包的软件在研究如何通过软件完成对网页数据的操作下面是我抓得数据包我的目的是

如何用vb开发一个发送http包的软件
在研究如何通过软件完成对网页数据的操作

下面是我抓得数据包
我的目的是用vb做一个可以登录网站的功能
界面我都会做,我想知道如何把用户名,密码发送到目标网站


HTML code
POST /user.asp?Action=chklogin HTTP/1.1Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*Referer: http://localhost/user.aspAccept-Language: zh-cnContent-Type: application/x-www-form-urlencodedAccept-Encoding: gzip, deflateUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)Host: localhostContent-Length: 73Connection: Keep-AliveCache-Control: no-cacheCookie: AJSTAT_ok_times=3; VFGNLVCWIGESOGSOGQOG=RVFBSTEJMIBASYKZGOZWTHEGYCCJAZOEABGVDICO; AJSTAT_ok_pages=5username=admin&pwd=123456&zd_code=3697&baoliu=&comurl=&login=%B5%C7%C2%BCHTTP/1.1 200 OKServer: NetBox Version 2.8 Build 4128Date: Sun, 11 Apr 2010 13:35:01 GMTConnection: Keep-AliveCache-control: privateContent-Type: text/htmlContent-Length: 1452<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gbk" /><title>会员中心-追梦阳光贴吧官方网站</title><meta name="Copyright" content="追梦阳光动力" /><meta name="keywords" content="追梦阳光贴吧 专业程序开发制作" /><meta name="description" content="追梦阳光贴吧2.0是一款短小精悍的ASP信息资讯发布展示系统,他集成了留言本的便捷,CMS的实用,论坛的交互性于一体。" /><link href="skins/200/style.css" rel="stylesheet" type="text/css" /><script type="text/javascript" src="images/jquery-1.3.2.min.js"></script><script type="text/javascript" src="images/js.js"></script></head><body><div id="header">    <div class="wrap s_clear">        <h2><a href="index.asp"><img src="skins/200/logo.png" border="0" /></a></h2>        <div id="umenu"><A href='user.asp'>登录</A> | <A href='user.asp?Action=reg'>注册</A> | <a href='user.asp?Action=restorePwd' title='按此找回密码'>忘记密码?</a></div>        <div id="ad_headerbanner">TieBa_AD_Top<!-- 广告位置 --></div>        <div id="menu">            <ul></ul>        </div>    </div></div><div id="nav"><span><ul></ul></span><div id="navpr"><a href="index.asp">追梦阳光贴吧官方网站</a> &raquo; 会员中心</div></div><div id="wrapper" class="wrap s_clear"><script>alert('用户名 或者 密码错误!');window.location.replace('user.asp');</Script>GET /user.asp HTTP/1.1Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*Accept-Language: zh-cnAccept-Encoding: gzip, deflateUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)Host: localhostConnection: Keep-AliveCookie: AJSTAT_ok_times=3; VFGNLVCWIGESOGSOGQOG=RVFBSTEJMIBASYKZGOZWTHEGYCCJAZOEABGVDICO; AJSTAT_ok_pages=5HTTP/1.1 200 OKServer: NetBox Version 2.8 Build 4128Date: Sun, 11 Apr 2010 13:35:05 GMTConnection: Keep-AliveCache-control: privateContent-Type: text/htmlContent-Length: 4762<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gbk" /><title>会员中心-追梦阳光贴吧官方网站</title><meta name="Copyright" content="追梦阳光动力" /><meta name="keywords" content="追梦阳光贴吧 专业程序开发制作" /><meta name="description" content="追梦阳光贴吧2.0是一款短小精悍的ASP信息资讯发布展示系统,他集成了留言本的便捷,CMS的实用,论坛的交互性于一体。" /><link href="skins/200/style.css" rel="stylesheet" type="text/css" /><script type="text/javascript" src="images/jquery-1.3.2.min.js"></script><script type="text/javascript" src="images/js.js"></script></head><body><div id="header">    <div class="wrap s_clear">        <h2><a href="index.asp"><img src="skins/200/logo.png" border="0" /></a></h2>        <div id="umenu"><A href='user.asp'>登录</A> | <A href='user.asp?Action=reg'>注册</A> | <a href='user.asp?Action=restorePwd' title='按此找回密码'>忘记密码?</a></div>        <div id="ad_headerbanner">TieBa_AD_Top<!-- 广告位置 --></div>        <div id="menu">            <ul></ul>        </div>    </div></div><div id="nav"><span><ul></ul></span><div id="navpr"><a href="index.asp">追梦阳光贴吧官方网站</a> &raquo; 会员中心</div></div><div id="wrapper" class="wrap s_clear"><form name="save" method="post" action="user.asp?Action=chklogin" onSubmit="return regcheck(this);"><br><br><table width="600" align="center" cellSpacing=1 cellPadding=0 class="zd_table" border=0>    <tr class="zd_td">    <td height="30" align="center" colspan=2><strong>用户登录</strong></td>    </tr><tr class="zd_td">    <td width="30%" height="30" align="right"><strong>帐 号:</strong></td>    <td>&nbsp;<input name="username" type="text" id="username" size="20" maxlength="20"> <span id="formct_username"></span></td>    </tr>  <tr class="zd_td">    <td height="30" align="right"><strong>密 码:</strong></td>    <td>&nbsp;<input name="pwd" type="password" id="pwd" size="20" maxlength="20"> <span id="formct_pwd"></span></td>    </tr>  <tr class="zd_td">    <td height="30" align="right"><strong>验证码:</strong></td>    <td>&nbsp;<input name="zd_code" type="text" id="zd_code" size="4" maxlength="4" onKeyPress="if ((event.keyCode<48 &&event.keyCode!=13) || event.keyCode>57) event.returnValue=false" onFocus="document.all.checkcode.src='inc/GetCode.asp?a=login&s='+Math.random()"/><img id='checkcode' src="images/circle.gif" alt= "验证码,看不清楚?请点击刷新验证码" style="cursor : pointer;" onclick="src='inc/GetCode.asp?a=login&s='+Math.random()"/> <span id="formct_zdcode"></span>    </td>    </tr>    <tr class="zd_td">    <td height="30" align="right"><strong>保留登录:</strong></td>    <td>&nbsp;<input type='radio' name='baoliu' value='' checked>否 <input type='radio' name='baoliu' value='365'>是</td>    </tr><tr class="zd_td">    <td height="30" align="right">&nbsp;</td>    <td><input name="submit3" type=button value='注册' onClick="window.location='user.asp?Action=reg'">      &nbsp;&nbsp;<input name="comurl" type="hidden" id="comurl" value="">      <input type=submit name=login id=login value=登录>    </tr></table>  <br><br></form><script language="JavaScript1.2">function regcheck(formct){    if (formct.username.value=='' ){        formct.username.focus();          document.getElementById("formct_username").innerHTML="<font color=red>帐号不能为空,请填写</font>";        return false;     }        if (formct.pwd.value=='' ){        formct.pwd.focus();          document.getElementById("formct_pwd").innerHTML="<font color=red>密码不能为空,请填写</font>";        return false;     }    if (formct.zd_code.value=='' ){        formct.zd_code.focus();          document.getElementById("formct_zdcode").innerHTML="<font color=red>验证码不能为空,请填写</font>";        return false;     }    formct.save.disabled=true;}</script></div><div id="footer">    <div id="bottom" class="s_clear">        <div id="footlink">            <div>                <strong><a href="http://tieba.dreamsun.cn/" target="_blank">追梦阳光贴吧官方网站</a></strong>                ( <a href="http://www.miibeian.gov.cn/" target="_blank">陕ICP备05008626号</a>)</div>                <div class="smalltext">                GMT+8, 2010-4-11 下午 09:35:05, <span id="debuginfo">页面执行<a href="so.asp?Action=c" title="清空缓存">0.000</a>毫秒/0</span><script language="javascript" type="text/javascript" src="http://js.users.51.la/3492964.js"></script></div>        </div>        <div id="rightinfo"><div>技术支持:<a href="http://www.dreamsun.cn" target="_blank" title=2010-3-6>DDP TieBa</a> <em>2.0.0</em></div><div>&copy; 2001-2010</div></div>        </div></div><script>get_msg();</script></body></html>GET /ajax.asp?a=get_msg_num&b=0.6003057804858034 HTTP/1.1x-requested-with: XMLHttpRequestAccept-Language: zh-cnReferer: http://localhost/user.aspAccept: text/html, */*Accept-Encoding: gzip, deflateUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)Host: localhostConnection: Keep-AliveCookie: AJSTAT_ok_times=3; VFGNLVCWIGESOGSOGQOG=RVFBSTEJMIBASYKZGOZWTHEGYCCJAZOEABGVDICO; AJSTAT_ok_pages=6HTTP/1.1 200 OKServer: NetBox Version 2.8 Build 4128Date: Sun, 11 Apr 2010 13:35:05 GMTConnection: Keep-AliveCache-control: privateContent-Type: text/html;charset=gb2312Content-Length: 0GET /go.asp?svid=4&id=3492964&tpages=6&ttimes=3&tzone=8&tcolor=32&sSize=1024,768&referrer=&vpage=http%3A//localhost/user.asp HTTP/1.1Accept: */*Referer: http://localhost/user.aspAccept-Language: zh-cnAccept-Encoding: gzip, deflateUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)Host: web1.51.la:82Connection: Keep-AliveHTTP/1.1 200 OKDate: Sun, 11 Apr 2010 13:35:06 GMTServer: Microsoft-IIS/6.0Content-Length: 0Content-Type: text/htmlExpires: Sat, 10 Apr 2010 20:55:06 GMTCache-control: private 



[解决办法]
1.使用Winsock控件
直接构造HTTP1.1协议报文,使用Winsock的SendDate方法发送,DateArrived事件内接受服务器的反馈即可。请参见老马的博客www.m5home.com。

2.使用XMLHTTP对象
引用Microsoft XML V6.0。实例化一个xmlhttp对象后,使用setRequestHeader方法设置相应的报文头,使用open方法发送请求报文(HTTP1.1协议),responseText接收反馈的文本(还有responseStream、responseXML)

热点排行