Я использую метод ниже, чтобы сделать HTTP-запрос в моем макросе VBA (скопированный с одного скопированных сайтов).VBA macro HTTP-запрос
Function GetURLStatus(ByVal URL As String, Optional AllowRedirects As Boolean)
Const WinHttpRequestOption_EnableRedirects = 6
If httpRequest Is Nothing Then
On Error Resume Next
Set httpRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
If httpRequest Is Nothing Then
Set httpRequest = CreateObject("WinHttp.WinHttpRequest.5")
End If
err.Clear
On Error GoTo 0
End If
' Control if the URL being queried is allowed to redirect.
httpRequest.Option(WinHttpRequestOption_EnableRedirects) = AllowRedirects
' Launch the HTTP httpRequest synchronously
On Error Resume Next
httpRequest.Open "GET", URL + "x", False
If err.Number <> 0 Then
MsgBox err.Number
' Handle connection errors
GetURLStatus = err.Description
err.Clear
Exit Function
End If
On Error GoTo 0
' Send the http httpRequest for server status
On Error Resume Next
httpRequest.SetTimeouts
httpRequest.Send
httpRequest.WaitForResponse
If err.Number <> 0 Then
' Handle server errors
'PageSource = "Error"
GetURLStatus = err.Description
err.Clear
Else
' Show HTTP response info
GetURLStatus = httpRequest.Status & " - " & httpRequest.StatusText
' Save the web page text
'PageSource = httpRequest.ResponseText
End If
On Error GoTo 0
End Function
Может кто-то пожалуйста, объясните, что цель httpRequest.SetTimeouts и httpRequest.WaitForResponse.
По умолчанию, сколько времени он будет ждать ответа HTTP, и что нужно модифицированном увеличить это время ожидания