更新时间:2023-10-17 17:36:46
您正在将登录详细信息发送到错误的登录地址.您的正确登录地址为 https://pnds.health.ny.gov/account/login该页面需要LoginName和Token.令牌是使用SecurityManager.generate(u,p);
You are sending login details to an incorrect login address. Your correct login address is https://pnds.health.ny.gov/account/login the page expects LoginName and Token. The token is generated using SecurityManager.generate( u, p );
您仍然可以咨询其IT团队,以确保您没有违反其政策.
这是使用IE浏览器对象的一种方法.
Here is a way of doing it using a IE browser object.
Private Sub DownloadValidationData()
'Create Internet explorer object
Dim IE As Object
Set IE = CreateObject("INTERNETEXPLORER.APPLICATION")
IE.Visible = True
Dim URL As String: URL = "https://pnds.health.ny.gov/account/login"
IE.Navigate URL
While IE.READYSTATE <> READYSTATE_COMPLETE
DoEvents
Wend
Dim userName As String: userName = "test"
Dim password As String: password = "test"
'Fill the login form
IE.Document.getElementById("UniqueUser").Value = userName
IE.Document.getElementById("UniquePass").Value = password
'Submit the form
IE.Document.querySelector("button.SignIn").Click
'Wait for login to complete
While IE.READYSTATE <> READYSTATE_COMPLETE
DoEvents
Wend
'Verify you are logged in: As we don't know what the site looks like after login in. Only you can do this step.
'Navigate to Download Page. This should prompt to save the file.
IE.Navigate theDownloadUrl '"https://pnds.health.ny.gov/xxxx/xxxx/8"
'Once downloaded just close the browser and exit
'IE.Quit
'Set IE = Nothing
'If you are interested in geting/generating the token using their script you can play around with below lines. These lines come before loging in. Please note: execScript is depreciated now
'Dim Token as string
'IE.Document.parentwindow.execScript ("$('#Token').val(SecurityManager.generate(""" & username & """, """ & password & """ ))")
'Token = IE.Document.getElementById("Token").Value
'Use the token to sign in using your code. That'll be xobj.Send "LoginName =" & userName & "&Token=" & Token
'But not sure if it will work.
End Sub