Ebola57 Posted January 4, 2023 Share Posted January 4, 2023 Hi community I am trying to get some basic information from printers in my network. For this I use such code expandcollapse popup#include <Constants.au3> Local $oHTTP = ObjCreate ( "winhttp.winhttprequest.5.1" ) Local $sHTML = "" http_get_example ( "hostname_to_check" ) Func http_get_example ( $sHostname ) Local $oHttp = Null, $oComErr = Null ;Register COM Error Handler $oComErr = ObjEvent("AutoIt.Error", com_error_handler) If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", "Unable to register COM error handler - @error = " & @error) ;Create HTTP COM object $oHttp = ObjCreate("winhttp.winhttprequest.5.1") If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", "Unable to create HTTP COM object - @error = " & @error) With $oHttp ;Open GET request .Open("GET", "http://" & $sHostname & ".enedis-grdf.fr/", False ) If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", StringFormat("(0x%X) %s", $oComErr.RetCode, $oComErr.WinDescription)) ;Send request .Send() If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", StringFormat("(0x%X) %s", $oComErr.RetCode, $oComErr.Description)) ConsoleWrite(StringFormat("HTTP Status: %s %s", .Status, .StatusText) & @CRLF) ;If http status code not 200 If .Status <> 200 Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", StringFormat("HTTP Status Code = %s %s", .Status, .StatusText)) ;Display response ConsoleWrite(@CRLF & "HTTP Response:" & @CRLF) ConsoleWrite(.ResponseText & @CRLF) EndWith EndFunc Func com_error_handler($oError) With $oError ConsoleWrite(@CRLF & "COM ERROR DETECTED!" & @CRLF) ConsoleWrite(" Error ScriptLine....... " & .scriptline & @CRLF) ConsoleWrite(" Error Number........... " & "0x" & Hex(.number) & " (" & .number & ")" & @CRLF) ConsoleWrite(" Error WinDescription... " & StringStripWS(.windescription, $STR_STRIPTRAILING) & @CRLF) ConsoleWrite(" Error Description...... " & StringStripWS(.description , $STR_STRIPTRAILING) & @CRLF) ConsoleWrite(" Error RetCode.......... " & "0x" & Hex(Number(.retcode)) & " (" & Number(.retcode) & ")" & @CRLF) EndWith Return ; Return so @error can be trapped by the calling function EndFunc On some printers it runs flawlessly, on some newer, I've got an error COM ERROR DETECTED! Error ScriptLine....... 25 Error Number........... 0x80020009 (-2147352567) Error WinDescription... An exception has occured (translated from french : Une exception s’est produite. ) Error Description...... The certificate authority is not valid or correct (translated from french : L’autorité de certification n’est pas valide ou correcte) Error RetCode.......... 0x80072F0D (-2147012851) Manually, I can bypass this warning, this is ths usual error when you browes an http site without 's', certificate error "I aknowledge teh risk, I anyway wnat to browe at my own risk bla bla" Is there a way to bypass such erro and follow browsing even if http and not https mode ? Regards Link to comment Share on other sites More sharing options...
TheXman Posted January 4, 2023 Share Posted January 4, 2023 Ebola57 1 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...
Ebola57 Posted January 4, 2023 Author Share Posted January 4, 2023 (edited) Thank you ! Now that problem is solved, I'd like to load from this printer Lexmark the specific page of network configuration in order to catch MAC address It seems to be accessible via JS Is there a way to do this with winhttprequest ? The tag that lead to this is : <li id="Settings-Reports-link"> <a class="navSection link navLink" href="#/Settings/Reports" tabindex = "202" > Here the page I want to access Here the HTML code Edited January 4, 2023 by Ebola57 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