I want use WinHttpRequest to access a OpenShift API server, it use a self signed certificate.
Does now work...
I never try with a self signed certificate, how do this?
Global $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "https://openshift.domain:1234/api/", False) $oHttp.Option(4) = 0x0100 + 0x0200 + 0x1000 + 0x2000 $oHTTP.Option(9) = 0x0080 ;WinHttpRequestOption_SecureProtocols ;~ $oHttp.SetClientCertificate("LOCAL_MACHINE\\Personal\\certificado.crt") $oHttp.Send() $oHttp.WaitForResponse() Local $oAllHeaders = $oHttp.GetAllResponseHeaders() $oReceived = $oHttp.ResponseText $oStatusCode = $oHttp.Status $oHttp = 0 If $oStatusCode = 200 Then ConsoleWrite("$oAllHeaders--------------------" & @LF & $oAllHeaders & "$oAllHeaders--------------------" & @LF) Else ConsoleWrite("< error = " & $oReceived & @LF & $oAllHeaders & @LF) EndIf
Hi Guys, I need help. I have searched the forum before posting and i couldn't find anything. The code below works fine when downloading files from "http" sites, but when trying to download from "https" sites, no files are downloaded. I tried different sites and I experience the same problem everywhere. Is there something I'm missing or doing wrong? Please note that I'm not a programmer and I'm new to this. I'm just using logic wherever i can to get things done. your help will be highly appreciated.
; Download a file in the background.
; Wait for the download to complete.
; Save the downloaded file to the temporary folder.
Local $sFilePath = "d:\"
; Download the file in the background with the selected option of 'force a reload from the remote site.'
Local $hDownload = InetGet("https://en.wikipedia.org/wiki/HTTPS#/media/File:Internet2.jpg", $sFilePath& "Internet2.jpg", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
; Retrieve the number of total bytes received and the filesize.
Local $iBytesSize = InetGetInfo($hDownload, $INET_DOWNLOADREAD)
Local $iFileSize = FileGetSize($sFilePath&"Internet2.jpg")
; Close the handle returned by InetGet.
; Display details about the total number of bytes read and the filesize.
MsgBox($MB_SYSTEMMODAL, "", "The total download size: " & $iBytesSize & @CRLF & _
"The total filesize: " & $iFileSize)
; Delete the file.
I was playing around with _INetGetSource(), and just seeing how it returned the bytes. It doesn't seem to return what I would expect, though. For example, I loaded up http://asdf.com/aboutasdf.html, and viewed the page source. Copy/ pasted that into a Notepad++ document, and I get a length of 2,481 characters > 2,481 bytes. When I do:
#include-once #include <Inet.au3> Global $sSource, $sSite = "http://asdf.com/aboutasdf.html" Global $iBytes $sSource = _INetGetSource($sSite) ;Get the page source for the account If Not @error Then ;As long as nothing goes wrong $iBytes += @extended ;Get number of bytes returned MsgBox(0, '', $iBytes & @CRLF & $sSource) ;Number of bytes, and the source ClipPut($sSource) Exit EndIf I get a return of 2,391 bytes (missing 90 bytes) from the @extended when I run _INetGetSource(). If I put the page source into my clipboard and paste that into the Notepad++ document, I still get 2,479 (it removed the top blank line that I get when selecting all from the page source in my browser). So the source that I copy from my browser, and that AutoIt puts in my clipboard is ~2,480 bytes. So, why is the @extended returning 2,391? Maybe I'm just missing something.
On just http://asdf.com/ it returns 1,892, which I get when copy/pasting as well, from the script and from the browser.
Im trying to get the information from https website, but it does not return any thing, here is the code:
Global $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$agent ='Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36'
$url = "https://www.sportinglife.com/racing/results"
$oHTTP.Open("GET", $url, False)
$oHTTP.setRequestHeader ("User-Agent", $agent)
$oHTTP.Option(4) = 13056
$src = ($oHTTP.ResponseText)
ConsoleWrite($url & @CRLF)
MsgBox(0, '$src', $src)
when i tried with other website, it is working, but this code does not works with this website. Pls help me
Good Morning AutoIT Geniuses!
Now, it could be that I've been away for a while - but I can get source from just about any website except adobe using InetGetSource.
I have no idea why... error: 13
#include <Inet.au3> HttpSetUserAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") Local $sOpenAdobe_URLSecurityUpdates = 'https://helpx.adobe.com/security.html' Local $OpenSSL01 = _INetGetSource($sOpenAdobe_URLSecurityUpdates) WinHttp.au3 is returning results - I just don't get it...
#include "WinHttp.au3" Opt("MustDeclareVars", 1) ; Initialize and get session handle Global $hOpen = _WinHttpOpen() ; Get connection handle Global $hConnect = _WinHttpConnect($hOpen, "helpx.adobe.com") ; Make a request Global $hRequest = _WinHttpSimpleSendRequest($hConnect, Default, "/security.html?promoid=HRYCM") If $hRequest Then ; Simple-read... ConsoleWrite(_WinHttpSimpleReadData($hRequest) & @CRLF) MsgBox(64, "Okey do!", "Returned source is print to concole. Check it.") Else MsgBox(48, "Error", "Error ocurred for _WinHttpSimpleSendRequest, Error number is " & @error) EndIf ; Close handles _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen)