登录网站并返回登​​录状态

时间:2020-06-21 09:42:57

标签: excel vba httprequest httpresponse

我需要登录到网站列表并返回登录状态。

我可以使用下面的VBA代码来验证URL,但是我不确定如何返回登录状态。

脚本:

    Function IsURLValid(URL As String) As Boolean
    

    
    
    Dim Request As Object
    Dim Result  As String

    On Error Resume Next
    

    Set Request = CreateObject("WinHttp.WinHttpRequest.5.1")
    If Err.Number <> 0 Then
        MsgBox "Could not create the WinHttpRequest object!", vbCritical, "WinHttpRequest Error"
        Exit Function
    End If
    
 
    Request.Open "GET", URL, False
    

    Request.send
    
   
    Result = Request.StatusText
            
    
    If InStr(1, Result, "OK", vbTextCompare) > 0 Then IsURLValid = True
    
    
    Set Request = Nothing

End Function

enter image description here

0 个答案:

没有答案