2016-12-24 97 views
1

我試圖在IE中執行javascript後獲取HTML代碼。這是我的代碼。如何使用Autoit執行JavaScript後獲取源代碼

$url = "http://example.com" 
$oIE = _IECreate($url) 
Sleep(3000) ;waiting for executing javascript. But useless. 
$oFrame = _IEFrameGetCollection($oIE, 0) 
$sCode &= _IEPropertyGet($oFrame, "innerhtml") & @CRLF 

然後,我得到這個錯誤。

"C:\Program Files (x86)\AutoIt3\Include\IE.au3" (2308) : ==> The requested action with this object has failed.: 
$oTemp = $oObject.document.body 
$oTemp = $oObject^ ERROR 

執行javascript後,當我在IE中查看源代碼時,有如下的HTML代碼。

<html> 
<head> 
... 
</head> 
<body> 
... 
</body> 
</html> 

我該怎麼辦?

回答

0

要閱讀整個頁面的來源,請使用_IEDocReadHTML

$url = "http://example.com" 
$oIE = _IECreate($url) 
Sleep(3000) ;waiting for executing javascript. But useless. 
$sCode &= _IEDocReadHTML($oIE) & @CRLF 
+0

此代碼在執行javascript之前獲取javascript代碼。 – modagi

相關問題