Global $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
Local $sCookieReturn = _GetCookieReturn()
If Not @error Then
Local $sCookie = '',$sRamdom = '',$sToken = ''
$sRamdom_reg = StringRegExp($sCookieReturn,'random=\d+',1)
If Not @error Then $sRamdom = $sRamdom_reg[0]
$sToken_reg = StringRegExp($sCookieReturn,'token=\w+',1)
If Not @error Then $sToken = $sToken_reg[0]
$sCookie = $sRamdom & ';' & $sToken
$sHtmlSource = _GetHtmlSource($sCookie)
MsgBox(0,0,$sHtmlSource);//获取网页源码
EndIf
Func _GetHtmlSource($sCookie)
$_geturl = 'http://www.dataoke.com/qlist'
$oHTTP.Open('GET', $_geturl, True)
If @error Then Return SetError(-1)
$oHTTP.Option(4) = 13056 ;忽略错误标志
$oHTTP.setRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
$oHTTP.setRequestHeader("Upgrade-Insecure-Requests", "1")
$oHTTP.setRequestHeader("Referer", $_geturl)
$oHTTP.setRequestHeader("Accept-Language", "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3")
$oHTTP.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 5.1; rv:52.0) Gecko/20100101 Firefox/52.0")
$oHTTP.setRequestHeader("Connection", "Keep-Alive")
$oHTTP.setRequestHeader("Host", "www.dataoke.com") ;
$oHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")
$oHTTP.setRequestHeader("Cookie", $sCookie)
$oHTTP.send()
If @error Then Return SetError(-2)
$oHTTP.WaitForResponse
If @error Then Return SetError(-3)
$sContent = $oHTTP.responsebody
If @error Then Return SetError(-4)
Return BinaryToString($sContent,4)
EndFunc
Func _GetCookieReturn()
$_geturl = 'http://www.dataoke.com/qlist'
$oHTTP.Open('GET', $_geturl, True)
If @error Then Return SetError(-1)
$oHTTP.Option(4) = 13056 ;忽略错误标志
$oHTTP.setRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
$oHTTP.setRequestHeader("Upgrade-Insecure-Requests", "1")
$oHTTP.setRequestHeader("Accept-Language", "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3")
$oHTTP.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 5.1; rv:52.0) Gecko/20100101 Firefox/52.0")
$oHTTP.setRequestHeader("Connection", "Keep-Alive")
$oHTTP.setRequestHeader("Host", "www.dataoke.com") ;
$oHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")
$oHTTP.send()
If @error Then Return SetError(-2)
$oHTTP.WaitForResponse
If @error Then Return SetError(-3)
$sHeader = $oHTTP.getAllresponseheaders
If @error Then Return SetError(-4)
Return $sHeader
EndFunc