DW1 Posted March 7, 2014 Posted March 7, 2014 No, of course credentials can't be passed automatically. Your browser saved credentials somewhere and passes them for domain (or whatever). Okay, makes sense. Thanks trancexx. AutoIt3 Online Help
aicoder Posted March 8, 2014 Posted March 8, 2014 That script have _WinHttpWriteData() that is not in WinHTTP.au3 (I wasn't sure about "str" or "wstr" in dll call). the above code is useful ,thanks !!
swoop Posted March 31, 2014 Posted March 31, 2014 Question about connecting with winHTTP on non-standard ports for HTTP or on a localhost. It seems I can connect to websites on my computer using winHTTP and GET/POST. But when I try to setup a web server on my local machine on a port such as 8884, it does not return any results. Local $hconnection = _WinHttpConnect($hsession, "localhost:8884") _WinHttpQueryDataAvailable($hrequest) just returns unavailable, and there is not data coming back from _WinHttpQueryHeaders and _WinHttpReadData. But when I submit the same GET/POST request on something like POSTMAN Chrome extension, there is no problem access localhost or localhost on a non-standard HTTP port. Is there something special I need to do in the _WinHttpConnect description of the local host? Thanks in advance. trancexx 1
trancexx Posted March 31, 2014 Author Posted March 31, 2014 Question about connecting with winHTTP on non-standard ports for HTTP or on a localhost. It seems I can connect to websites on my computer using winHTTP and GET/POST. But when I try to setup a web server on my local machine on a port such as 8884, it does not return any results. Local $hconnection = _WinHttpConnect($hsession, "localhost:8884") _WinHttpQueryDataAvailable($hrequest) just returns unavailable, and there is not data coming back from _WinHttpQueryHeaders and _WinHttpReadData. But when I submit the same GET/POST request on something like POSTMAN Chrome extension, there is no problem access localhost or localhost on a non-standard HTTP port. Is there something special I need to do in the _WinHttpConnect description of the local host? Thanks in advance. Yes, port number is third parameter for that function. Just read description from the help file and pass port number as third argument. swoop 1 ♡♡♡ . eMyvnE
swoop Posted April 1, 2014 Posted April 1, 2014 Yes, port number is third parameter for that function. Just read description from the help file and pass port number as third argument. Ah... so very helpful. Very grateful. That's a total miss on my part. A good rule: Read the documentation again Late night programming does that. Thank you again.
Guest Posted May 3, 2014 Posted May 3, 2014 Hello, I have a problem.I can not read this test page: https://googledrive.com/host/0B-dsGBArc-IuVHdIRFFyUV8xSXc/host-in-drive.html from googledrive with this example: expandcollapse popup#include <Array.au3> #include "WinHttp.au3" Opt("MustDeclareVars", 1) Global $hOpen , $hConnect , $hRequest ; Initialize $hOpen = _WinHttpOpen() ; Specify what to connect to $hConnect = _WinHttpConnect($hOpen, "https://googledrive.com/host/0B-dsGBArc-IuVHdIRFFyUV8xSXc/host-in-drive.html") ; <- yours here ; Create request $hRequest = _WinHttpOpenRequest($hConnect) ; Send it _WinHttpSendRequest($hRequest) ; Wait for the response _WinHttpReceiveResponse($hRequest) ;MsgBox(0,"","test") ; See if there is data to read Global $sChunk, $sData If _WinHttpQueryDataAvailable($hRequest) Then ; Read While 1 ToolTip("test") $sChunk = _WinHttpReadData($hRequest) If @error Then ExitLoop $sData &= $sChunk WEnd ConsoleWrite($sData & @CRLF) ; print to console Else MsgBox(48, "Error", "Site is experiencing problems.") EndIf ; Close handles when they are not needed any more _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) I using WinHttp v1.6.3.7 it working only with "yahoo.com". What's the problem?
trancexx Posted May 3, 2014 Author Posted May 3, 2014 You are calling it wrong. Just read functions' headers about parameters. There is also help file in the package with plethora of examples, try some and work from there maybe. ♡♡♡ . eMyvnE
Guest Posted May 3, 2014 Posted May 3, 2014 You are calling it wrong. Just read functions' headers about parameters. There is also help file in the package with plethora of examples, try some and work from there maybe. You do not know how many times I tried to make it work without success before I comment here ..I'd appreciate it if you at least point me to the right direction.. thanks
trancexx Posted May 3, 2014 Author Posted May 3, 2014 See example for WinHttpSimpleSendSSLRequest. All you need to do is change input data. Even simpler would be to use WinHttpSimpleSSLRequest. ♡♡♡ . eMyvnE
trancexx Posted May 7, 2014 Author Posted May 7, 2014 So anyway, in case you're still trying maybe this would help: #include "WinHttp.au3" $sDomain = "https://googledrive.com" $sPage = "host/0B-dsGBArc-IuVHdIRFFyUV8xSXc/host-in-drive.html" ; Initialize and get session handle $hOpen = _WinHttpOpen() ; Get connection handle $hConnect = _WinHttpConnect($hOpen, $sDomain) ; SimpleSSL-request it... $sReturned = _WinHttpSimpleSSLRequest($hConnect, Default, $sPage) ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; See what's returned MsgBox(0, "Returned", $sReturned) ♡♡♡ . eMyvnE
Guest Posted May 7, 2014 Posted May 7, 2014 (edited) So anyway, in case you're still trying maybe this would help: #include "WinHttp.au3" $sDomain = "https://googledrive.com" $sPage = "host/0B-dsGBArc-IuVHdIRFFyUV8xSXc/host-in-drive.html" ; Initialize and get session handle $hOpen = _WinHttpOpen() ; Get connection handle $hConnect = _WinHttpConnect($hOpen, $sDomain) ; SimpleSSL-request it... $sReturned = _WinHttpSimpleSSLRequest($hConnect, Default, $sPage) ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; See what's returned MsgBox(0, "Returned", $sReturned) Thank you.You would not need to bother .. I was going to try what you said anyway. I just took a break. I will test it. I don't like the point that if the url is in https protocol then i should call it a different way. I would prefer a function that get URL - no matter if it is http or https and then gives the output, which is the downloaded data. I don't know how much it is complex to write a function that only decides how to call to the function based on the type of the URL. I guess it's an easy thing to do. so if i will decide to use your UDF, I'll try to do it Edited May 7, 2014 by Guest
Guest Posted May 12, 2014 Posted May 12, 2014 (edited) So anyway, in case you're still trying maybe this would help: #include "WinHttp.au3" $sDomain = "https://googledrive.com" $sPage = "host/0B-dsGBArc-IuVHdIRFFyUV8xSXc/host-in-drive.html" ; Initialize and get session handle $hOpen = _WinHttpOpen() ; Get connection handle $hConnect = _WinHttpConnect($hOpen, $sDomain) ; SimpleSSL-request it... $sReturned = _WinHttpSimpleSSLRequest($hConnect, Default, $sPage) ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; See what's returned MsgBox(0, "Returned", $sReturned) Can you please give an example how to do it during a loop without stopping the script? I don't know if this is the correct way to do it: #include "WinHttp.au3" $sDomain = "https://googledrive.com" $sPage = "host/0B-dsGBArc-IuVHdIRFFyUV8xSXc/host-in-drive.html" ; Initialize and get session handle $hOpen = _WinHttpOpen() ; Get connection handle $hConnect = _WinHttpConnect($hOpen, $sDomain) ; SimpleSSL-request it... ;~ $sReturned = _WinHttpSimpleSSLRequest($hConnect, Default, $sPage) $timer0 = TimerInit() $test = _WinHttpSimpleSendSSLRequest($hConnect,Default,$sPage) ConsoleWrite(TimerDiff($timer0)&@CRLF) $timer = TimerInit() While 1 ToolTip("test") If TimerDiff($timer) > 5000 Then ExitLoop If _WinHttpQueryDataAvailable($test) = 1 Then ConsoleWrite(_WinHttpReadData($test)&@CRLF) ExitLoop EndIf WEnd ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; See what's returned According to my test, this is not the right way ... Edited May 12, 2014 by Guest
trancexx Posted May 12, 2014 Author Posted May 12, 2014 Then you read inside the (main) script loop with _WinHttpReadData specifying the size of read data (third parameter of the function). ♡♡♡ . eMyvnE
Guest Posted May 12, 2014 Posted May 12, 2014 (edited) Then you read inside the (main) script loop with _WinHttpReadData specifying the size of read data (third parameter of the function). but it takes about 600ms - 1000ms for line: $test = _WinHttpSimpleSendSSLRequest($hConnect,Default,$sPage) to finish. is it normal? I think it happens because this function is waiting for the page to finish load.. this code proves my point. #include "WinHttp.au3" $sDomain = "https://googledrive.com" $sPage = "host/0B-dsGBArc-IuVHdIRFFyUV8xSXc/host-in-drive.html" ; Initialize and get session handle $hOpen = _WinHttpOpen() ; Get connection handle $hConnect = _WinHttpConnect($hOpen, $sDomain) ; SimpleSSL-request it... ;~ $sReturned = _WinHttpSimpleSSLRequest($hConnect, Default, $sPage) $timer0 = TimerInit() $test = _WinHttpSimpleSendSSLRequest($hConnect,Default,$sPage) ConsoleWrite(TimerDiff($timer0)&@CRLF) ConsoleWrite(_WinHttpReadData($test)&@CRLF) ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; See what's returned It works without a loop .. it means that the function is waiting until the page is fully loaded Edited May 12, 2014 by Guest
trancexx Posted May 12, 2014 Author Posted May 12, 2014 It means connecting to the site and waiting for it to reply to your request takes that time. ♡♡♡ . eMyvnE
Guest Posted May 12, 2014 Posted May 12, 2014 (edited) It means connecting to the site and waiting for it to reply to your request takes that time. yes. but at that time i need that the script will keep working.. 600ms-1000ms is bad because my script connects to more than one url. so i need that this part of loading & connecting the urls and downloading the data will occur in background. is this possible with your UDF with HTTPS? if so then please give me an example of downloading a page into a variable in background from HTTPS url. thanks Edited May 12, 2014 by Guest
trancexx Posted May 15, 2014 Author Posted May 15, 2014 Everything is possible, only you need to understand this UDF and AutoIt better. ♡♡♡ . eMyvnE
Guest Posted May 15, 2014 Posted May 15, 2014 (edited) Sorry that I do not understand how to use this UDF.for some reason, it's the only UDF I could not figure out how to use it properly after many attempts to figure out how to do what I want ..I'll keep trying to figure out how to use it Edited May 15, 2014 by Guest
guinness Posted May 16, 2014 Posted May 16, 2014 Sorry that I do not understand how to use this UDF.Erm ... this is one of the best well documented UDFs I know that isn't part of AutoIt.My new saying is "lack of code, lack of trying!" mLipok 1 UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
Guest Posted May 16, 2014 Posted May 16, 2014 No matter, I see that I'm not the only one who wanted to do it. I see someone else asked the same thing here. I probably missed it .. There's a lot of pages here. Anyway, I think I got the answer. EDIT: Ok, tested the answer that i found in >#427 And that example is working. I understand that the example shows how to do it in the background. But the problem is that this part in the example: $sUrl = 'https://www.magroup-online.com/IBA/ES/ES/IBA_ES_es_PaymentSecurity.html' $hOpen = _WinHttpOpen() $aCrackedUrl = _WinHttpCrackUrl ( $sUrl ) $hConnect = _WinHttpConnect($hOpen, $aCrackedUrl[2], $INTERNET_DEFAULT_HTTPS_PORT) $hRequest = _WinHttpOpenRequest($hConnect, Default, $aCrackedUrl[6], Default, Default, Default, $WINHTTP_FLAG_SECURE) _WinHttpSendRequest($hRequest) _WinHttpReceiveResponse($hRequest) Takes about 500ms-700ms to finish - And this fact makes it not really background.. I mean - i know that after this part is finish, the rest of the action is occurs is in background(when the loop is active) but before that loop, the operation works too slowly and i can't call it "in background" because it is slow.. this for example: $timer = TimerInit() InetGet('https://www.magroup-online.com/IBA/ES/ES/IBA_ES_es_PaymentSecurity.html',"test",Default,1) ConsoleWrite(TimerDiff($timer)&@CRLF) Is something that takes very short time to finish. it takes 5ms - 8ms. This is the time that i would expect from the first code..
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