本帖最后由 xyhqqaa 于 2018-10-10 09:53 编辑
GET /vcode-index-passport3035239.html?d=0.32243579872802175 HTTP/1.1
Host: mall.phicomm.com
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
Accept: image/webp,image/apng,image/*,*/*;q=0.8
Referer: https://mall.phicomm.com/checkout-fastbuy.html
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Cookie: _VMC_UID=788a8f8c2afe2a0024e05f952236bcf0; __jsluid=7cc4215441e92b4edbe7a439b2813f96; __guid=97137667.641827650283735700.1526365823606.815; _SID=ea85157610f2af2c5dd5897a8b9905e0; MEIQIA_EXTRA_TRACK_ID=18uBgp0p726oUFCNbVSr9pcqCoQ; Hm_lvt_4532b50bd635e230f63e966a610afe18=1534820674,1534839892,1535013380,1535679830; Hm_lvt_d7682ab43891c68a00de46e9ce5b76aa=1536807674,1536894162; Hm_lvt_c8bb97be004001570e447aa3e00ff0ad=1536945073,1537097048,1537114421,1537114606; UNAME=13616040945; MEMBER_IDENT=3035239; MEMBER_LEVEL_ID=2; CACHE_VARY=f636871e5813c35b6acc712e3fae8801-47587e393d1368226b29aa1662628b0a; from_vshopid=null; monitor_count=23; c_peisong=1; c_zhifu=alipay
抓包获取的信息
$oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
$oHTTP.Option(4) = 13056 ;忽略错误标志
$oHTTP.Option(6) = True;是否接收重定向地址信息
$oHTTP.SetTimeouts(30000, 30000, 30000, 30000);超时时间设置
Func getvcode();获取验证码
$oHTTP.Open('GET', 'https://mall.phicomm.com/vcode-index-passport3035239.html', False)
$oHTTP.setRequestHeader('Host','mall.phicomm.com')
$oHTTP.setRequestHeader('Connection',' keep-alive')
$oHTTP.setRequestHeader('Accept','application/json, text/javascript, */*; q=0.01')
$oHTTP.setRequestHeader('Origin','https://mall.phicomm.com')
$oHTTP.setRequestHeader('X-Requested-With','XMLHttpRequest')
$oHTTP.setRequestHeader('User-Agent','Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36')
$oHTTP.setRequestHeader('Content-Type','image/png')
$oHTTP.setRequestHeader('Referer','https://mall.phicomm.com/checkout-fastbuy.html')
$oHTTP.setRequestHeader('Accept-Language','zh-CN,zh;q=0.8')
$oHTTP.send()
$getcodeoReturnWebS=BinaryToString($oHTTP.responseBody)
$hFO = FileOpen('test.png', 2 + 16)
FileWrite($hFO, $oHTTP.responseBody)
FileClose($hFO)
Return $getcodeoReturnWebS
EndFunc
以上代码可以获取验证码图片
#include 'WinHTTP.au3'
Global $sHeader, $sReturned,$getcodeReturned
Global $mallAddress = "mall.phicomm.com"
Global $orderAddress = "https://mall.phicomm.com/checkout-fastbuy.html"
Global $hOpen = _WinHttpOpen("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"); 打开所需句柄
Global $hConnect = _WinHttpConnect($hOpen, $mallAddress, $INTERNET_DEFAULT_HTTPS_PORT); 获取连接句柄 $INTERNET_DEFAULT_PORT = 0, $INTERNET_DEFAULT_HTTP_PORT = 80, $INTERNET_DEFAULT_HTTPS_PORT = 443
Func getvcode();获取验证码
$getcodePage = "vcode-index-passport3035239.html"
;$getcodeRequest = _WinHttpOpenRequest($hConnect, "get", $getcodePage, -1, -1, -1, $WINHTTP_FLAG_SECURE); 指定请求
$getcodeRequest = _WinHttpOpenRequest($hConnect, "get", $getcodePage)
_WinHttpAddRequestHeaders( $getcodeRequest, "Content-Type:application/x-www-form-urlencoded; charset=UTF-8"); 向请求添加文件头
_WinHttpAddRequestHeaders( $getcodeRequest, "Accept:image/webp,image/apng,image/*,*/*;q=0.8")
_WinHttpAddRequestHeaders( $getcodeRequest, "Connection:keep-alive")
_WinHttpAddRequestHeaders( $getcodeRequest, "Host:"&$mallAddress)
_WinHttpAddRequestHeaders( $getcodeRequest, "Accept-Language:zh-CN,zh;q=0.9")
_WinHttpAddRequestHeaders( $getcodeRequest, "Referer:"&$orderAddress)
;_WinHttpAddRequestHeaders( $getcodeRequest, "Cookie:"&$sHeader)
_WinHttpReceiveResponse( $getcodeRequest); 等待应答
_WinHttpSendRequest($getcodeRequest, -1,""); 发送数据
_WinHttpReceiveResponse($getcodeRequest); 等待应答
$getcodeReturned &= _WinHttpReadData($getcodeRequest);返回值
$hFO = FileOpen('test.png', 2 + 16)
FileWrite($hFO,$getcodeReturned)
FileClose($hFO)
_WinHttpCloseHandle( $getcodeRequest); 关闭句柄
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)
EndFunc
使用以上代码可以获取下载验证码图片,这几天刚学winhttp不清楚用啥参数好,论坛资料好少。。使用winhttp却无法下载验证码图片。求大佬指教
没找到。。。。先结案
|