怎么获取get请求返回的数据流?[已解决]
本帖最后由 kinghu318 于 2011-3-30 10:53 编辑$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.option(6)=0
$oHTTP.SetTimeouts(5000,5000,5000,5000)
$oHTTP.Open("GET", "http://reg.qq.com/cgi-bin/checkconn?seed0.6754959910853089",True)
;$ohttp.open("get","http://reg.qq.com")
;$oHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
;$oHTTP.setRequestHeader("($equest-Line)","GET /cgi-bin/checkconn?seed0.6754959910853089 HTTP/1.1");
$oHTTP.setRequestHeader("Accept","*/*");
$oHTTP.setRequestHeader("Accept-Encoding","gzip, deflate");
$oHTTP.setRequestHeader("Accept-Language","zh-cn");
$oHTTP.setRequestHeader("Connection","Keep-Alive");
$oHTTP.setRequestHeader("Cookie","o_cookie=5733721; pgv_pvid=7512144518; pgv_flv=10.0; pgv_r_cookie=111470311834; adid=5733721; adSP=EaUSAOEsFdCCtCXVCb/pXdRBouwK86mFWS9I6x2bggo=_58209_326830_1295572352_; adVer=1833; ac=1,015,; ptcz=1fd9aceda80011406287055058e0a88efc33a13e52610de3c855d36b21858725; AREACODE=1|11|; PCCOOKIE=68612f36e4967017a394312166f98e2cee5dae105c00261e306f695d110f1e90; PCCOOKIE2=2470457838; verifysession=h00088c865c1e27da0c0a127d3020e5dea9bd5a9fceb9b623775f47e5598158aff400034d76431342d1; pgv_info=pgvReferrer=&ssid=s7290891111; htc=67592; vipqq1=1e492dcf4704133ddea6ec02489a1d0e; vipqq2=1301366156; vipqq3=434270681; wdl=82f6bc947b90f8b85b0e7425aff14774b3da185a40d6a43107ff0895275becb0; qzone=1; uts=398c07833d54d753aaf7a708fbb0aec075d65148342cd9a951667789ce858cf0");
$oHTTP.setRequestHeader("Host","reg.qq.com");
$oHTTP.setRequestHeader("Referer","http://reg.qq.com/");
$oHTTP.setRequestHeader("UA-CPU","x86");
$oHTTP.setRequestHeader("User-Agent","Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)");
$oHTTP.send("")
MsgBox(0,"",$oHTTP.responseText)
获取不到信息,在get监视中可以看到返回的流,应该要怎么获取,各位老大帮忙。。。谢谢。。。
我这里运行这个 有返回信息 不过是 服务器错误信息
Frame: Number = 8832, Captured Frame Length = 1340, MediaType = ETHERNET
+ Ethernet: Etype = Internet IP (IPv4),DestinationAddress:,SourceAddress:
+ Ipv4: Src = 183.60.2.90, Dest = 192.168.1.19, Next Protocol = TCP, Packet ID = 14317, Total IP Length = 1326
+ Tcp: Flags=...AP..., SrcPort=HTTP(80), DstPort=2718, PayloadLen=1286, Seq=1354731534 - 1354732820, Ack=1872766438, Win=7259 (scale factor 0x0) = 7259
- Http: Response, HTTP/1.1, Status: Internal server error, URL: /cgi-bin/checkconn
ProtocolVersion: HTTP/1.1
StatusCode: 500, Internal server error
Reason: Internal Server Error
Date:Tue, 29 Mar 2011 09:54:25 GMT
Server:Apache
Vary:accept-language,accept-charset
Accept-Ranges:bytes
Connection:close
+ ContentType:text/html; charset=iso-8859-1
Content-Language:en
HeaderEnd: CRLF
- payload: HttpContentType =text/html; charset=iso-8859-1
HtmlElement: <?xml version="1.0" encoding="ISO-8859-1"?>
HtmlElement:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
HtmlElement:
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
HtmlElement:
<head>
HtmlElement:
<title>
HtmlElement: Server error!</title>
HtmlElement:
<link rev="made" href="mailto:webmaster@tencent.com" />
HtmlElement:
<style type="text/css">
HtmlElement: <!--/*-->
HtmlElement: <![CDATA[/*>
HtmlElement: <!--*/
body { color: #000000; background-color: #FFFFFF; }
a:link { color: #0000CC; }
p, address {margin-left: 3em;}
span {font-size: smaller;}
/*]]>
HtmlElement: */-->
HtmlElement: </style>
HtmlElement:
</head>
HtmlElement:
<body>
HtmlElement:
<h1>
HtmlElement: Server error!</h1>
HtmlElement:
<p>
HtmlElement:
The server encountered an internal error and was
unable to complete your request.
</p>
HtmlElement:
<p>
HtmlElement:
Error message:
<br />
HtmlElement: Premature end of script headers: checkconn
</p>
HtmlElement:
<p>
HtmlElement:
If you think this is a server error, please contact
the <a href="mailto:webmaster@tencent.com">
HtmlElement: webmaster</a>
HtmlElement: .
</p>
HtmlElement:
<h2>
HtmlElement: Error 500</h2>
HtmlElement:
<address>
HtmlElement:
<a href="/">
HtmlElement: reg.qq.com</a>
HtmlElement: <br />
HtmlElement:
<span>
HtmlElement: Tue Mar 29 17:54:25 2011<br />
HtmlElement:
Apache</span>
HtmlElement:
</address>
HtmlElement:
</body>
HtmlElement:
</html>
HtmlElement:
回复 2# xayle
返回的是错误信息,但是我想获得返回的流,我那个图片上有记录get请求过去后返回的流,但是不知道怎么去获取那个流,你有什么办法获取请求返回的流吗? 直接打开reg.qq.com并没有你那个url出现, 用IE打开那个url提示服务器错误 不清楚你的这个想获取啥。
如果是注册验证码,请从http://captcha.qq.com/getimage?aid=????? 中获取。
想偷懒也不是这么做的,Cookies每次都会变,请一步步来处理。 GetAllResponseHeaders()
如$oHTTP.GetAllResponseHeaders,将会返回全部的http头信息.以@crlf分割
获取单个信息可以使用GetResponseHeader( BSTR Header)
调用方法:
$oHTTP.GetResponseHeaders("Set-Cookie"),将会返回Set-Cookie的值
另外,提醒下楼主,获取验证码是不用设置Cookies的,只是要取而已.
还有就是最好使用wininet或winhttp又或winsock操作,因为可以轻易继承session,对一些没做限制的网站可以只验证一次就能持续使用. 回复 5# republican
谢谢回复,我不是获取验证码,我的想要获取一个加密数组,申请QQpost的数据,都是通过一个数组进行加密的,那个数据就是我监视到的g_dataArray的值,是通过get请求http://reg.qq.com/cgi-bin/checkconn?seed"&random()所获得的,我就是想获得返回的g_dataArray....图片上的流的那部分 回复 6# ceoguang
谢谢指导,头信息是可以获取到的,嘻嘻我看了你发过的一个帖子,但是我现在想获取的是流,我通过能够监视到返回的结果,但是我完全根据请求来,却老是返回错误的信息者是监视的结果:
看不清楚你想表达什么。
都到这地步了就发代码上来吧 回复 9# ceoguang
不好意思,可能我表达得不够清楚,您可以用HttpWatch Studio 工具监视注册QQ的过程reg.qq.com,在注册过程中会有一个GET请求到http://reg.qq.com/cgi-bin/checkconn?seed"&random()这个地址,然后会返回一个类型为:application/x-javascript的内容,我就想获得那个内容。。。谢谢。。。。 回复 10# kinghu318
代码我也没具体的代码,我是通过腾讯注册的js里找的....我按照工具监视的信息进行提交,但是就是获取不到所要的值。。。。不知道什么原因,难道application/x-javascript类型的值不能用responseText进行获取?哎,头都大了。。。 谢谢各位的帮助终于解决了
$oHTTP = ObjCreate("Microsoft.XMLHTTP");这里必须是xmlhttp可以
$oHTTP.Open("GET", "http://reg.qq.com/cgi-bin/checkconn?seed0.6754959910853089",True)
$oHTTP.setRequestHeader("Accept","*/*");
$oHTTP.setRequestHeader("Accept-Encoding","gzip, deflate");
$oHTTP.setRequestHeader("Accept-Language","zh-cn");
$oHTTP.setRequestHeader("Connection","Keep-Alive");
;$oHTTP.setRequestHeader("Cookie",$Cookie)
$oHTTP.setRequestHeader("Cookie","o_cookie=5733721; pgv_pvid=7512144518; pgv_flv=10.0; pgv_r_cookie=111470311834; adid=5733721; adSP=EaUSAOEsFdCCtCXVCb/pXdRBouwK86mFWS9I6x2bggo=_58209_326830_1295572352_; adVer=1833; ac=1,015,; ptcz=1fd9aceda80011406287055058e0a88efc33a13e52610de3c855d36b21858725; AREACODE=1|11|; PCCOOKIE=68612f36e4967017a394312166f98e2cee5dae105c00261e306f695d110f1e90; PCCOOKIE2=2470457838; verifysession=h00088c865c1e27da0c0a127d3020e5dea9bd5a9fceb9b623775f47e5598158aff400034d76431342d1; pgv_info=pgvReferrer=&ssid=s7290891111; htc=67592; vipqq1=1e492dcf4704133ddea6ec02489a1d0e; vipqq2=1301366156; vipqq3=434270681; wdl=82f6bc947b90f8b85b0e7425aff14774b3da185a40d6a43107ff0895275becb0; qzone=1; uts=398c07833d54d753aaf7a708fbb0aec075d65148342cd9a951667789ce858cf0");
$oHTTP.setRequestHeader("Host","reg.qq.com");
$oHTTP.setRequestHeader("Referer","http://reg.qq.com/");
$oHTTP.setRequestHeader("UA-CPU","x86");
$oHTTP.setRequestHeader("User-Agent","Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)");
$oHTTP.send("")
MsgBox(0,"",$oHTTP.responseText)
Content-Type对返回的responseText有影响,只有xmlhttp的形式机会不影响,所有用winhttp根本获取不到值。。。谢谢大家的帮助。。。
地方
你的{:face (303):}
页:
[1]