我有一个简单的脚本登录网页,但现在我需要构建一个VB脚本,如果我点击一个按钮
答案 0 :(得分:0)
Simlply在脚本中输入用户名和密码的位置。
如下 .getelementbyid(" userid")。value = range(" a1")。value 同样适用于pw。 .getelementbyid("密码")。value = range(" a2")。value
答案 1 :(得分:0)
考虑使用它。
Set ie = CreateObject("InternetExplorer.application")
' Get username and password from worksheet. Not very secure, but this way the credentials are always sitting in the same spot and the user doesn't have to enter these each time.
' Alternative is to use an input box toprompt the user for crednetials.
UserName = Worksheets("ControlSheet").Range("A1").Value
Password = Worksheets("ControlSheet").Range("A2").Value
With ie
.Visible = True
.navigate "YOUR_1ST_URL_HERE"
' Wait for the page to fully load; you can't do anything if the page is not fully loaded
Do While .Busy Or _
.readyState <> 4
DoEvents
Loop
On Error Resume Next
'Credentials are passed to the site and the button is clicked (by the code).
ie.document.forms(0).all("username").Value = UserName
ie.document.forms(0).all("password").Value = Password
ie.document.forms(0).submit.Click
' Wait for the page to fully load; you can't do anything if the page is not fully loaded
Do While .Busy Or _
.readyState <> 4
DoEvents
Loop
.navigate "YOUR_2ND_URL_HERE"
Do While .Busy Or _
.readyState <> 4
DoEvents
Loop