使用VBA登录到安全的https网站 [英] Log in to secured https website with VBA

查看:925
本文介绍了使用VBA登录到安全的https网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过VBA脚本自动登录我的银行帐户并从网站返回一些数据来自动化我的日常任务。但是,我无法编写可以登录到此网站的宏 -



以下代码google.com:

  Sub LoginHttps()

Dim IE As Object
设置IE = CreateObject(InternetExplorer.Application )

与IE
.Top = 0
.Left = 0
.Height = 1000
.Width = 1250
。可视= True
.Nav igatehttps://www.google.com/?gfe_rd=cr&ei=N-TZVaPMAdCv8wf19aH4Bw&gws_rd=cr&fg=1

尽管.Busy还是不.ReadyState = 4: DoEvents:Loop

.Document.getElementById(lst-ib)。Value =input
End with
End Sub

和银行网站代码产生424错误:

  Sub LoginHttps()

Dim IE As Object
设置IE = CreateObject(InternetExplorer.Application)

与IE
。 Top = 0
.Left = 0
.Height = 1000
.Width = 1250
.Visible = True
.Navigatehttps://online.mbank。 pl / pl / login

Do While .Busy or not .ReadyState = 4:DoEvents:Loop

.Document.getElementById(userID)。Value =input
结束
End Sub

我想知道是否有任何方法通过VBA或它访问这些输入框由银行程序员保护。

解决方案

这是三个顺序检查:第一个 Do ... Loop 是IE状态的通常检查,第二 - 文档完整性检查和第三个目标元素检查,它在目标节点未准备就绪时返回 Null 而不是 HTMLInputElement 。)

  Sub LoginHttps()
Dim IE As Object
设置IE = CreateObject(InternetExplorer.Application)
与IE
.Top = 0
.Left = 0
.Height = 1000
.Width = 1250
.Visible = True
。导航https://online.mbank.pl/pl/Login
尽管.Busy还是不。 readyState = 4:DoEvents:Loop
Do Until .document.readyState =complete:DoEvents:Loop
Do While TypeName(.document.getElementById(userID))=Null:DoEvents:循环
.document.getElementById(userID)。Value =in放
结束
结束子


I am trying to automate my daily tasks by VBA script automatically login into my bank account and returning some data from the website. However, I cannot write such macro which could login in into this website - https://online.mbank.pl/pl/Login.

I wrote the following macro which works well with "normal" websites such google (based on input box IDs), but does not work with bank websites returning, the following error:

Run-time error 424: Object required

Below code for google.com:

Sub LoginHttps()

    Dim IE As Object
    Set IE = CreateObject("InternetExplorer.Application")

    With IE
        .Top = 0
        .Left = 0
        .Height = 1000
        .Width = 1250
        .Visible = True
        .Navigate "https://www.google.com/?gfe_rd=cr&ei=N-TZVaPMAdCv8wf19aH4Bw&gws_rd=cr&fg=1"

        Do While .Busy Or Not .ReadyState = 4: DoEvents: Loop

        .Document.getElementById("lst-ib").Value = "input"
    End With
End Sub

and code for bank website which generates an 424 error:

Sub LoginHttps()

    Dim IE As Object
    Set IE = CreateObject("InternetExplorer.Application")

    With IE
        .Top = 0
        .Left = 0
        .Height = 1000
        .Width = 1250
        .Visible = True
        .Navigate "https://online.mbank.pl/pl/Login"

        Do While .Busy Or Not .ReadyState = 4: DoEvents: Loop

        .Document.getElementById("userID").Value = "input"
    End With
End Sub

I am wondering whether there is any method to access these input boxes by VBA or it is secured by bank programmers.

解决方案

Here are three sequential checks: first Do ... Loop is usual check of IE state, second - document completeness check, and third - target element check, which returns Null for me while target node not ready (instead of HTMLInputElement when it does).

Sub LoginHttps()
    Dim IE As Object
    Set IE = CreateObject("InternetExplorer.Application")
    With IE
        .Top = 0
        .Left = 0
        .Height = 1000
        .Width = 1250
        .Visible = True
        .Navigate "https://online.mbank.pl/pl/Login"
        Do While .Busy Or Not .readyState = 4: DoEvents: Loop
        Do Until .document.readyState = "complete": DoEvents: Loop
        Do While TypeName(.document.getElementById("userID")) = "Null": DoEvents: Loop
        .document.getElementById("userID").Value = "input"
    End With
End Sub

这篇关于使用VBA登录到安全的https网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆