Jump to content

$oHTTP.Open load value from txt file


autoitxp
 Share

Recommended Posts

_LoadVarHTTP("http://127.0.0.1:89/loadvars/files/update.txt")

is it possible to load value of variable from url .txt file ?

file contain like

$server1 = server1.1234.com

$server2 = server2.1234.com

Func _LoadVarHTTP($URLtoLoad)
    Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")
    Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
    If @error Then Return
    $oHTTP.Open("GET", $URLtoLoad, False)
    If @error Then Return
    $oHTTP.Send()
    If @error Then Return
    ;$oHTTP.WaitForResponse
    ConsoleWrite($oHTTP.Status & @CRLF)
    If $oHTTP.Status <> $HTTP_STATUS_OK Then Return
    Local $oHTTPSource = $oHTTP.Responsetext
    Local $oHTTPFileOpen = FileOpen(@ScriptDir & '\' & test.txt 2)
    FileWrite($oHTTPFileOpen, $oHTTPSource)
    FileClose($oHTTPFileOpen)
    ConsoleWrite($oHTTPSource)
EndFunc   ;==>_LoadVarHTTP
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...