Я пытаюсь загрузить файл с веб-сайта, на который я захожу, однако приглашение сохранения вызывает у меня проблемы.
Я пытался использовать sendkeys, но он не отправлял нажатия клавиш, также пыталсязагрузка с xmlhttp после входа в систему с помощью Internet Explorer.Я не понимаю, почему это так сложно.
'Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub login()
Const Url$ = "https://www.hedgefundresearch.com/user/login"
Dim oLogin As Object, oPassword As Object, oButton As Object, HTMLdoc As Object
Dim UserName As String, Password As String
UserName = "yyyyy@zzzz.com"
Password = "password"
Dim ie As Object, myURL As String
Set ie = CreateObject("InternetExplorer.Application")
ie.navigate Url
ie.Visible = True
Do Until ie.ReadyState = 4
DoEvents
Loop
Set HTMLdoc = ie.document
Set oLogin = HTMLdoc.getElementsByClassName("form-control form-text required")(0)
Set oPassword = HTMLdoc.getElementsByClassName("form-control form-text required")(1)
Set oButton = HTMLdoc.getElementsByClassName("btn btn-primary form-submit icon-before")(0)
On Error Resume Next
oLogin.Value = UserName
On Error Resume Next
oPassword.Value = Password
On Error Resume Next
oButton.Click
myURL = "https://www.hedgefundresearch.com/download/index-ror-perf-download/2899"
ie.navigate myURL
'AppActivate "zzz@yyyy.net | Hedge Fund Research® - Internet Explorer"
'Sleep 1
Application.SendKeys ("%s")
End Sub
Есть ли какие-нибудь простые способы сделать это?Все открывается и входит в систему нормально, но мне нужно пройти через этот диалог сохранения, Спасибо
РЕДАКТИРОВАТЬ: запрос заголовков
GET /download/index-ror-perf-download/2899 HTTP/1.1
Host: www.hedgefundresearch.com
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
Referer: https://www.hedgefundresearch.com/indices/hfri-fund-weighted-composite-index
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Cookie: _ga=GA1.2.1864475516.1551721637; COOKIE_TOU=2019-03-04+11%3A47%3A19; cookiesession1=297E7ACEBCDZVZC3YAZR1VC8IWL6AF6D; has_js=1; _gid=GA1.2.2018233246.1554731723; SSESScd329e696f514d42291a588234027dae=G6jjp0oCZUb2FjW43IXgTVZAOsb2UbyoU7iawYa2erw
General:
Request URL: https://www.hedgefundresearch.com/download/index-ror-perf-download/2899
Request Method: GET
Status Code: 200 OK
Remote Address: 167.88.151.170:443
Referrer Policy: no-referrer-when-downgrade