本帖最后由 fastidium 于 2012-12-17 09:51 编辑
我的源码:#include <WinHTTP_GetRespond.au3>
one()
Sleep(100)
two()
Func one()
$MyOpen = _WinHttpOpen()
$url = "http://searchb.dangdang.com/index.php?key1=%B4%BA%B7%E7%B2%BB%B8%C4&key4=&key2=%D1%F4%CC%A8%D2%BB%D3%E7&key3=&category_path=01.00.00.00.00.00&medium=01"
ConsoleWrite($url & @CRLF)
$rContext = _WinHTTP_GetRespond($MyOpen, $url, 2, 80000)
;ConsoleWrite($rContext[0])
If FileExists("soure1.txt") Then FileDelete("soure1.txt")
FileWrite("soure1.txt", $rContext[0])
EndFunc ;==>one
Func two()
$oHTTP = ObjCreate("microsoft.xmlhttp")
Local $url1 = "http://searchb.dangdang.com/index.php?key1=%B4%BA%B7%E7%B2%BB%B8%C4&key4=&key2=%D1%F4%CC%A8%D2%BB%D3%E7&key3=&category_path=01.00.00.00.00.00&medium=01"
ConsoleWrite($url1 & @CRLF)
$oHTTP.open("get", $url1, False)
$oHTTP.send()
$source1 = $oHTTP.responsetext
;MsgBox(0,0,$source1)
If FileExists("soure2.txt") Then FileDelete("soure2.txt")
FileWrite("soure2.txt", $source1)
EndFunc ;==>two
对ie操作我一直很迷茫,学习没有头绪,上面这两个源码也是从论坛修改的,用 ObjCreate这个能正确返回源码,为什么用WinHTTP_GetRespond这个不能正确返回源码呢?求各位老大指教啊,先谢谢了!
key1 key4 由转码工具得到:MsgBox(0,"",UrlEnc("春风不改"))
MsgBox(0,"",UrlEnc("阳台一隅"))
Func UrlEnc($Sz_url)
Local $str=StringTrimLeft(StringToBinary($Sz_url,1),2)
Local $ret
For $i=1 to StringLen($str) Step 2
$ret &='%' & StringMid($str,$i,2)
Next
Return $ret
EndFunc
|