wpzzz Posted February 14, 2018 Posted February 14, 2018 $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("GET","https://www.taiwanlotteryevent.com.tw",False) $oHTTP.Send The requested action with this object has failed.
Zedna Posted February 14, 2018 Posted February 14, 2018 Your script works fine for me. What OS/AutoIt versions do you have? Just to be sure, try: $oHTTP.Send() Resources UDF ResourcesEx UDF AutoIt Forum Search
wpzzz Posted February 15, 2018 Author Posted February 15, 2018 10 hours ago, Zedna said: Your script works fine for me. What OS/AutoIt versions do you have? Just to be sure, try: $oHTTP.Send() but i got fail win7 X64 3.3.14.2
Zedna Posted February 15, 2018 Posted February 15, 2018 Then add COM error handler to your script to see detailed error message: Global $oMyError = ObjEvent ("AutoIt.Error", "ErrorHandler") Func ErrorHandler() $HexNumber = Hex($oMyError.number, 8) MsgBox(16, "CHYBA", "Došlo k chybě!" & @CRLF & @CRLF & _ "Popis chyby: " & @TAB & $oMyError.description & @CRLF & _ "Win. popis:" & @TAB & $oMyError.windescription & @CRLF & _ "Číslo řádku: " & @TAB & $oMyError.scriptline & @CRLF & _ "Číslo chyby: " & @TAB & $HexNumber & @CRLF & _ "Objekt: " & @TAB & $oMyError.source, 0, $Form1) SetError(1) EndFunc Probably problem on your machine with DLL for " WinHttp.WinHttpRequest.5.1 " and ObjCreate fails. Resources UDF ResourcesEx UDF AutoIt Forum Search
Zedna Posted February 15, 2018 Posted February 15, 2018 (edited) With your URL I got this detailed COM error message (from COM error handler) : Connection with server not established. With different URL the same script works fine. Global $oMyError = ObjEvent ("AutoIt.Error", "ErrorHandler") $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("GET","https://www.taiwanlotteryevent.com.tw",False) $oHTTP.Send() Func ErrorHandler() $HexNumber = Hex($oMyError.number, 8) MsgBox(16, "CHYBA", "Došlo k chybě!" & @CRLF & @CRLF & _ "Popis chyby: " & @TAB & $oMyError.description & @CRLF & _ "Win. popis:" & @TAB & $oMyError.windescription & @CRLF & _ "Číslo řádku: " & @TAB & $oMyError.scriptline & @CRLF & _ "Číslo chyby: " & @TAB & $HexNumber & @CRLF & _ "Objekt: " & @TAB & $oMyError.source, 0, 0) SetError(1) EndFunc Edited February 15, 2018 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
TheXman Posted February 15, 2018 Posted February 15, 2018 I thought the issue may be related to not having an appropriate User-Agent request header, but that wasn't an issue. I tried it with the original URL, both with and without a User-Agent request header, and I got a valid response back each time. Here's the snippet I ran: $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("GET","https://www.taiwanlotteryevent.com.tw",False) ;~ $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0") $oHTTP.Send() ConsoleWrite($oHTTP.StatusText & @CRLF) ConsoleWrite(StringLeft($oHTTP.ResponseText, 1000) & @CRLF) Here's the ConsoleWrite output I received: OK <!doctype html> <html lang="zh-hant"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv ="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.5, user-scalable=1" /> <link rel="stylesheet" href="css/style.css" type="text/css"> <link rel="stylesheet" href="css/font-awesome.min.css"> <link rel="icon" href="//www.taiwanlotteryevent.com.tw/images/16x16.ico" type="image/x-icon" /> <link rel="shortcut icon" href="//www.taiwanlotteryevent.com.tw/images/16x16.ico" type="image/x-icon" /> <title>???????? ??????</title> <meta property="og:title" itemprop="name" content="???????? ??????" /> <meta name="description" content="???????? ??????" /> <meta property="og:description" content="???????? ??????" /> <meta itemprop="description" content="???????? ??????" /> <meta property="og:image" content="//www.taiwanlotteryevent.com.tw/images/1200x630.png" /> 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
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