|
楼主 |
发表于 2011-9-3 15:15:29
|
显示全部楼层
回复 3# republican
我也想用au3中提供的winhttp,但我怎么试也没有发送成功,服务器端的jieshou.asp文件什么都接收不到:
服务器的地址:192.168.0.1 web的端口为801 ,
录入网页:http://192.168.0.1:801/input.html
接收网页:http://192.168.0.1:801/jieshou.asp
我把httpwatch抓取得信息如下:
POST /jieshou.asp HTTP/1.1
Accept: application/x-shockwave-flash, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, */*
Referer: http://192.168.0.1:801/input.html
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)
Host: 222.135.111.108:801
Content-Length: 53
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: lzstat_uv=267122783216614645|2575321
ck1=%D5%C5%C8%FD&ck1=%C0%EE%CB%C4&Submit=%CC%E1%BD%BB
我运用winhttp写的代码如下:
Global $sPostData = "ck1=%D5%C5%C8%FD&ck1=%C0%EE%CB%C4&Submit=%CC%E1%BD%BB"
$saddress = "192.168.0.1"
; 初始化并获得会话句柄
Global $hOpen = _WinHttpOpen()
; 获取连接句柄
Global $hConnect = _WinHttpConnect($hOpen, $saddress, 801)
; Request
Global $hRequest = _WinHttpOpenRequest($hConnect, _
"POST", _ ; verb
"http://192.168.0.1:801/jieshou.asp", _ ; target
Default, _ ; version
"http://192.168.0.1:801/input.html", _ ; referer
"*/*") ; accept
; 确保启用 cookies
_WinHttpSetOption($hRequest, $WINHTTP_OPTION_DISABLE_FEATURE, $WINHTTP_DISABLE_COOKIES)
; 添加到请求头的字段
$jg = _WinHttpAddRequestHeaders($hRequest, "Accept-Language: zh-cn")
$jg = _WinHttpAddRequestHeaders($hRequest, "Content-Type: application/x-www-form-urlencoded")
$jg = _WinHttpAddRequestHeaders($hRequest, "Accept-Encoding: gzip, deflate")
$jg = _WinHttpAddRequestHeaders($hRequest, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)")
$jg = _WinHttpAddRequestHeaders($hRequest, "Host: 192.168.0.1:801")
$jg = _WinHttpAddRequestHeaders($hRequest, "Connection: Keep-Alive")
$jg = _WinHttpAddRequestHeaders($hRequest, "Cache-Control: no-cache")
; 发送
_WinHttpSendRequest($hRequest, -1, $sPostData)
好心人帮我看看,好吗? |
|