This topic is now closed to further replies.
I'm trying to download a file from our server at work which requires a login.
InetGet is not working so I was looking round for another method.
I came across winhttp.au3 but it seems like this is not shipped with the Autoit ZIP I have. (v3.3.14)
Anyone have any ideas of where to get it, because I can't find it.
I also searched the forum, thinking it was trancexx who made it. (maybe I'm wrong here....)
Or is it obsolete and is there another / better way?
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)
It is the second time I am running to this problem again. First time I used simple form fill function from winhttp.au3. And I added a sleep between logins to make it work but this solution sucks.
So I am wondering again, is there an other solution to perform a log in on website other than simple form fill?
I just want to check credentials so I need to perform log in and then check for the username in the results.
Here is an example with simple form fill
#include "WinHttp.au3" Global $sRead, $hOpen, $hConnect Global $sUsername, $sPassword, $sName Global $sUrl = "https://www.facebook.com/" Global $sUserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)" $hOpen = _WinHttpOpen($sUserAgent) $hConnect = _WinHttpConnect($hOpen, $sUrl) $sRead = _WinHttpSimpleFormFill($hConnect, _ Default, _ "login_form", _ "name:email", $sUsername, _ "name:pass", $sPassword) If @error Then MsgBox(0, "Error", "Error: " & @error) ElseIf StringInStr($sRead, $sName) = True Then MsgBox(0, "", $sName & "'s credentials are correct.") Else MsgBox(0, "", "Wrong credentials, please try again.") EndIf _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen)
I am trying to make an auto log in script that will log in on our server with all the accounts of the people working on our domain read from the database(arround 20 accounts). The reason for this is everyone to recive update e-mail.
We recive update e-mail with the latest updates everytime time we log in so that is the reason that i am creating this.
Here is a small reproducer:
#include "WinHttp.au3" OnAutoItExitRegister("_sExit") Global $sRead, $hOpen, $hConnect Global Const $sUsername = ["name1", "name2", "name3"] Global Const $sPassword = ["pass1", "pass2", "pass3"] Global Const $sUrl = "https://www.myServer.com/" Global Const $sUserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)" Local $a Local $b $hOpen = _WinHttpOpen($sUserAgent) $hConnect = _WinHttpConnect($hOpen, $sUrl) For $i = 0 To UBound($sUsername)-1 $a = $sUsername[$i] $b = $sPassword[$i] $sRead = _WinHttpSimpleFormFill($hConnect, _ Default, _ "login_1", _ "name:name", $a, _ "name:pass", $b) If @error Then ConsoleWrite(@error & @LF) Else If StringInStr($sRead, $a) Then ConsoleWrite($a & " succesfully logged in." & @LF) EndIf Next Func _sExit() _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) EndFunc If i put the $hOpen and $hConnect within the For/Next loop it will work but it will take more than 1 min to log in on our server with all the accounts.
If not it won't work for all the accounts. If i use $hOpen and $hConnect only once then the server will fire error after 4-5 log ins and the winhttpsimpleformfill function will return that there are no forms, @error 1.
Any other way to perform a log in without filling the form with data and submitting it?