如何找到给定网站的用户名和密码参考?

时间:2019-10-18 00:40:23

标签: vba authentication passwords username

我在这里有点不明白。尝试编写代码以启动espn.com/login,输入登录详细信息,然后访问api数据。此刻卡住了如何引用用户名和密码。这是我到目前为止的代码。

Sub login()

Const Url$ = "https://www.espn.com/login"

Dim UserName As String, Password As String, wss As Worksheet
Set wss = Worksheets("PowerRankings")
UserName = LoginData.Cells(6, "C").Value
Password = LoginData.Cells(7, "C").Value

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

With ie

    .Navigate Url
    ieBusy ie
    .Visible = True

    Dim oLogin As Object, oPassword As Object
    Set oLogin = .Document.getElementsByName("i_need_this")(0)
    Set oPassword = .Document.getElementsByName("and_this")(0)

    oLogin.Value = UserName
    oPassword.Value = Password
    .Document.forms(0).submit

End With

结束子

谢谢

编辑:意识到问题的一部分,登录页面包含在iframe中,据我所知,没有ID,类或标记名可供我参考以获取用户名和密码。

    Set loginFrame = .Document.getElementById("disneyid-iframe")
    Set HTMLdoc = loginFrame.contentWindow

    Dim oLogin As Object, oPassword As Object
    Set oLogin = HTMLdoc.getAttribute("placeholder") = "Username or Email Address"
    Set oPassword = HTMLdoc.getAttribute("placeholder") = "password"

    oLogin.Value = UserName
    oPassword.Value = Password
    HTMLdoc.forms(0).submit
<input type="email" placeholder="Username or Email Address" autocapitalize="none" autocomplete="on" autocorrect="off" spellcheck="false" ng-model="vm.username" 
ng-pattern="/^[^<&quot;>]*$/" ng-required="true" did-disable-validate="" ng-focus="vm.resetUsername()" class="ng-pristine ng-invalid ng-invalid-required 
ng-valid-pattern ng-touched" tabindex="0" required="required" aria-required="true" aria-invalid="true">

0 个答案:

没有答案