Acce Posted August 9, 2020 Share Posted August 9, 2020 Hi I have had major break through with my project this weekend and have been able to successfully communicating with the server im working with. However My latest request I got the HTML document as a response from the server when I try to read like so: Func _GetResopnse($string) $sChunk = "" $sData = "" ConsoleWrite("Response " & $string & @CRLF) If _WinHttpQueryDataAvailable($hRequest) Then ; Read While 1 $sChunk = _WinHttpReadData($hRequest) If @error Then ExitLoop $sData &= $sChunk WEnd ConsoleWrite(" " & $sData & @CRLF) ; print to console ; <== Check login status If StringInStr($sData, '"success":true') Then ;MsgBox(0, "", "Login success") Else ;MsgBox(0, "", "Login failed") EndIf Else MsgBox(48, "Error", "Site is experiencing problems.") EndIf ConsoleWrite("/Response" & @CRLF) ConsoleWrite(@CRLF) EndFunc This works very well in the consolelog however I want to write all this data into a textfile. I thought that would be simple enough doing something like this Local Const $htmlFilePath = @ScriptDir & "\System\htmldoc.txt" Local $hFileOpen = FileOpen($htmlFilePath, $FO_APPEND) FileWrite($hFileOpen, $sData) FileClose($hFileOpen) But with this I only get a blank txt document. any pointers to what I could do ? Link to comment Share on other sites More sharing options...
Danp2 Posted August 9, 2020 Share Posted August 9, 2020 Does it work it you add $FO_BINARY? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
TheXman Posted August 10, 2020 Share Posted August 10, 2020 (edited) 21 hours ago, Acce said: any pointers to what I could do ? Have you looked at InetGet()? It will get the result of an HTTP GET request and put the result in a file, all in one function call. Or, you can look at InetRead(), which will do the same thing as InetGet() except the result is a binary string instead of a saving the result in a file. Edited August 10, 2020 by TheXman Fixed InetRead() hyperlink CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Acce Posted August 14, 2020 Author Share Posted August 14, 2020 @ TheXman Thanks for the info , will do some testing now thanks for pointing me in the right direction Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now