Jump to content

how to translate responsetext to innertext


Recommended Posts

this is my code as follow:

#include <IE.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>



$Form1 = GUICreate("Form1", 903, 600, 267, 206)
$Edit1 = GUICtrlCreateEdit("responsetext", 8, 24, 425, 281)
$Edit2 = GUICtrlCreateEdit("$oIE.document.body.innerText", 440, 24, 449, 281)
$Button1 = GUICtrlCreateButton("test", 328, 312, 241, 30)
Global $oIE = _IECreateEmbedded()
GUICtrlCreateObj($oIE, 0, 350,  900,200 )
_IENavigate($oIE, "about:blank")
    
    GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case  $Button1
            test()
    EndSwitch
WEnd

Func test()
    Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
    $oHTTP.Open("GET",'https://www.autoitscript.com', False)
    $oHTTP.Send()
        
    Local $res = $oHTTP.responsetext
        
        
        $oIE.document.write($res)   
        Local $what_i_need = $oIE.document.body.innerText
    
    
    GUICtrlSetData($Edit1,$res)
    GUICtrlSetData($Edit2,$what_i_need)
    
    MsgBox(0,'this is the data i need:',$what_i_need)
EndFunc

 

in my code , $what_i_need  is the data i need

with ie obj ,  I can  translate  $res  to  $what_i_need  :

$oIE.document.write($res)   
        Local $what_i_need = $oIE.document.body.innerText

 

But  i  don't want to use ie obj   ,so  how can i  translate  $res  to  $what_i_need ?

ie.thumb.jpg.771076e6c788c491cbf0a6ce288bc436.jpg

Edited by fenhanxue
Link to comment
Share on other sites

You could do this:

Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
$oHTTP.Open("GET", 'https://www.autoitscript.com', False)
$oHTTP.Send()
Local $sResponseText = $oHTTP.ResponseText


Local $omHtmlFile = ObjCreate("mhtmlfile")
;~ ConsoleWrite(IsObj($oObject) & @CRLF)
$omHtmlFile.write($sResponseText)
Local $sInnerText=$omHtmlFile.body.innerText
ConsoleWrite($sInnerText & @CRLF)

Saludos

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...