Jump to content
fenhanxue

how to translate responsetext to innertext

Recommended Posts

fenhanxue

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

Share this post


Link to post
Share on other sites
fenhanxue
5 hours ago, Danp2 said:

Have you considered using _IECreate with the option to keep the window hidden?

i do not want to use the ie object  

so _IECreate is not   available  

 

Share this post


Link to post
Share on other sites
jdelaney

Load up the response into microsoft.xmldom (forum search this, many examples).  it also has an innertext ability.

  • Like 1

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
Danyfirex

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

  • Like 1

Share this post


Link to post
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

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.