Hi I am trying to use a code found here on the site that logs in on a website using
WinHTTP.WinHTTPrequest.5.1
but I can't get the login part to work, I have looked in the source code from the website, and it uses a form to login so I have added the "name" from the forms login fields, the username(Email) and the password(Password) but it doesn't do the job. how I know this is I have set the script to download a file that is only available when you're logged in, so the file is made as a copy of the page if it isn't logged in.
I know the problem is in this line:
strAuthenticate = "https://birdie.in.th/en/login=%2F&Email=" & logUser & "&Password=" & logPass & "&switch=Login"
I suspect it is the first in the line where I give the url is this wrong, can some explain how to use the
WHTTP.send
with password So I understand how to do this any help is much appreciated
Full Code
Dim FileNum As Long
Dim FileData() As Byte
Dim WHTTP As Object
Dim mainUrl, fileUrl, filePath, logUser, logPass, strAuthenticate As String
mainUrl = "https://birdie.in.th/en/login"
fileUrl = "https://birdie.in.th/golfgroups/exportusers/24.xls"
filePath = "C:\Users\Lasse\Downloads\myfile.xls"
logUser = "username"
logPass = "I-Used-my-pass-here"
strAuthenticate = "https://birdie.in.th/en/login=%2F&Email=" & logUser &
"&Password=" & logPass & "&switch=Login"
Set WHTTP = CreateObject("WinHTTP.WinHTTPrequest.5.1")
WHTTP.Open "POST", mainUrl, False
WHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
WHTTP.send strAuthenticate
WHTTP.Open "GET", fileUrl, False
WHTTP.send
FileData = WHTTP.responseBody
Set WHTTP = Nothing
FileNum = FreeFile
Open filePath For Binary Access Write As #FileNum
Put #FileNum, 1, FileData
Close #FileNum
I have tried different things also been working with doing it all in IE browser but that is really not the way I want to go. I have been reading about the
WHTTP.send
here on the site and google but I haven't really found anything that explains how to pass the credentials properly to the site. so if you have a solution for it so that it worsk or just somewhere where I can get information on how to get this to work, would help me a lot thanks.
Aucun commentaire:
Enregistrer un commentaire