谁和我讲下vb中INET和VB.NET中HttpWebRequest POST的区别,另关于QQ农场

thestronger 2009-12-04 09:25:53
想用VB.NET做一个在PPC手机上玩的QQ农场程序。
结果在登录这里就把我难住了。
参照了QQ伴侣的源码,它使用了一个INET控件
Dim posttem As String
posttem = "u=123456789&p=" & "mypassword" & "&verifycode=" & Text3.Text & "&aid=15000102&u1=http%3A%2F%2Fxiaoyou.qq.com%2Findex.php%3Fmod%3Dlogin&fp=&h=1&ptredirect=1&ptlang=0&from_ui=1&dumy="
Inet1.Execute "http://ptlogin2.qq.com/login", "POST", posttem


这样,网页会返回密码错误。

在VB.NET中,由于没有inet,在手机上也不能用webclient。所以我只好这样:
Dim wq As HttpWebRequest = HttpWebRequest.Create(url)
wq.Method = "POST"
wq.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-silverlight, */*"
wq.UserAgent = " Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; TencentTraveler 4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 2.0.50727)"
Dim encoding As New ASCIIEncoding()
posttem = "u=123456789&p=" & "mypassword" & "&verifycode=" & Text3.Text & " &aid=15000101&u1=http%3A%2F%2Fimgcache.qq.com%2Fqzone%2Fv5%2Floginsucc.html%3Fpara%3Dizone&fp=loginerroralert&h=1&ptredirect=1&ptlang=0&from_ui=1&dumy="
Dim byte1 As Byte() = encoding.GetBytes(posttem)
wq.ContentLength = byte1.Length
wq.ContentType = "application/x-www-form-urlencoded"
Dim whead As WebHeaderCollection = wq.Headers
whead.Add("Accept-Language: zh-cn")
whead.Add("Accept-Encoding: gzip, deflate")

Dim newStream As Stream = wq.GetRequestStream()
newStream.Write(byte1, 0, byte1.Length)

Dim wp As HttpWebResponse = wq.GetResponse
Dim receiveStream As Stream = wp.GetResponseStream()
newStream.Close()

Dim readStream As New StreamReader(receiveStream, ASCIIEncoding.UTF8)


MsgBox(readStream.ReadToEnd())
wp.Close()
readStream.Close()


URL和发送的数据完全一样。返回的结果却是“系统繁忙”。
搞不懂什么区别了!!!


另外,正常登录时,抓取的HTTP包内容是:
POST /login HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-silverlight, */*
Referer: http://ui.ptlogin2.qq.com/cgi-bin/login?link_target=blank&appid=15000101&s_url=http%3A//php.qzone.qq.com/index.php%3Fmod%3Dportal%26act%3Dlogin&f_url=loginerroralert&target=top&qlogin_jumpname=jump&qlogin_param=u1%3Dhttp%3A//php.qzone.qq.com/index.php%3Fmod%3Dportal%26act%3Dlogin
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; TencentTraveler 4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 2.0.50727)
Host: ptlogin2.qq.com
Content-Length: 211
Connection: Keep-Alive
Pragma: no-cache
Cookie: o_cookie=404471692; pvid=4067959302; flv=10.0; r_cookie=952479654239; adid=404471692; adSP=13cAz3e4YXPuikC22IL/XLcnocQolwm0tKx6IGq5IOQ=_37272_326830_1259424545_; pt2gguin=o0404471692; ptcz=0df5aa892baf505e893dcd67e7e44501e2674e60d3e4f95709d9ef267f0bdfe1; adVer=2515; ac=1,030,015; avid=b/fwfKB+QS1hZyoQfMJ4s3O3xi9PbC3EaSZlZ2aT3/b+ekaf8QRl30jk++q45OFOLj7N1lPqg1M=; icache=@D@@CEBMF; webqq_setting=1343225856; randomSeed=2680382; AREACODE=1|44|19; PCCOOKIE=b61e454247fb9ca70b60d10f0849dd3b1ab3b3d0407d45b53cbe0135efc8c270; PCCOOKIE2=3982681645; showModel=list; suid=1713950051; gkey=whe2J0PQUgademJF7Ab%2BfNGZtaLccLwmqGtRdy78LWH8jxi7TZe7Ujoz1V5byjAqgNS8DoNU1H8%3D; ispai2_404471692=2; QQ_Index_IP_1HrCache=%u5E7F%u4E1C%u7701%2C%u4E1C%u839E%u5E02; ispai2_1182092120=2; verifysession=f31262459727f153840fb34bff5edae316e065be0d27ce0696b799b2bdcd6ba73c6aebd4987cad88



而用上面的VB.NET代码,抓的包是:

POST /login HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-silverlight, */*
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; TencentTraveler 4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 2.0.50727)
Content-Type: application/x-www-form-urlencoded
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
Host: ptlogin2.qq.com
Content-Length: 215
Expect: 100-continue

已经非常接近了,,就是搞不懂为什么都是返回系统繁忙?!

xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>腾讯登录页面</title>
<style type="text/css">
<!--
body,td,th {
font-family: "宋体",Verdana, Arial;
font-size: 12px;text-align: left;}
.btn{
border:1px solid #eeeeee; height:20px; width:50px; font-family: "宋体",Verdana, Arial ;font-size: 12px; text-align: center;
FILTER: progid:DXImageTransform.Microsoft.Gradient(startColorStr=#ffffff,endColorStr=#C6C5D7)}
-->
</style>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" style="border:1px solid #0D7CCB">
<tr>
<td height="23" align="left" valign="middle" bgcolor="#0D7CCB"><span style="font-size:14px; font-weight:bold; color:#ffffff; padding:10px">提示信息</span></td>
</tr>
<tr>
<td align="center" valign="middle"><label></label>
<table style="padding:10px" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" align="left" valign="top"><span style="font-size:13px; line-height:17px;">
系统繁忙,请稍后重试(24)。</span></td>
</tr>
</table></td>
</tr>
<tr>
<td height="30" valign="bottom"><div align="center"><a style="CURSOR:hand"><input style="CURSOR:hand" name="Submit" type="button" class="btn" onclick=javascript:window.history.back() value="确 定" /></a></div></td>
</tr>
<tr>
<td height="15" align="center"> </td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
...全文
538 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hzz1988 2010-01-07
  • 打赏
  • 举报
回复
我用JAVA做的 你和我遇到的问题一摸一样。 我显示登录失败 系统繁忙
stonewang 2009-12-07
  • 打赏
  • 举报
回复
建议用从C++
thestronger 2009-12-06
  • 打赏
  • 举报
回复
不知道是不是还要发送cookie过去,“verifysession=3624687ccdc86a3e50c3ee0625716e2a95f2f559811bda18b962a8f85e5416e9c1ba4878c1c8737f”
郁闷的是在.net cf中连cookie也不支持了,不知道怎么解决
beijingtianbai 2009-12-05
  • 打赏
  • 举报
回复
HttpWebRequest

7,655

社区成员

发帖
与我相关
我的任务
社区描述
Windows Phone是微软发布的一款手机操作系统,它将微软旗下的Xbox LIVE游戏、Zune音乐与独特的视频体验整合至手机中。
社区管理员
  • Windows客户端开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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