簡體   English   中英

使用VBA腳本登錄網站登錄頁面

[英]Using a VBA script to login to a website Login Page

我正在嘗試使用Google和此站點上的資源來幫助我,但我正在努力在登錄頁面的輸入框中輸入用戶名和密碼。

該頁面位於我們的工作服務器上的本地網絡上。

登錄頁面的HTML代碼:

<TD background=/frontend/images/greenback.gif width=302><INPUT maxLength=32 name=username> </TD>

<TD background=/frontend/images/greenback.gif width=302><INPUT maxLength=32 type=password value="" name=password> </TD>

到目前為止,我已經嘗試過:

Sub Test()

On Error Resume Next

Dim sUrl As String: sUrl = "https://workplace.plus.net/index.html?"
Dim ie As Object

Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True

ie.navigate sUrl

Do While ie.readystate <> 4: DoEvents: Loop

ie.document.getElement.Name("username").Value = 1234

End Sub

我也嘗試過:

ie.document.getElement.Name("username").Value = 1234
ie.document.getElement.Id("username").Value = 1234
ie.document.getElement.Class("username").Value = 1234
ie.document.getElement.Type("username").Value = 1234

ie.document.getElementByClassName("username").Value = 1234
ie.document.getElementById("username").Value = 1234
ie.document.getElementByName("username").Value = 1234
ie.document.getElementByType("username").Value = 1234

問題是我在Google上使用ID按鈕使用了相同的代碼,並且可以正常工作。 有沒有我沒有考慮的東西?

在這里,我正在使用Facebook登錄頁面。 您可以放置​​任何其他鏈接來登錄,將sUser作為字符串,將sPass作為字符串。 分配要輸入的值。 Application.Wait(Now + TimeValue(“ 00:00:02”))是加載頁面與添加登錄ID和密碼之間的時間。 另一方面,將傳遞用戶ID和密碼IE.Document.all.Item(“ email”)。Value = sUser。 請嘗試此代碼

Sub facebookPost()
Dim IE As Object
Dim sUser As String, sPass As String


sUser = "1234"
sPass = "1234"

Set IE = CreateObject("INTERNETEXPLORER.Application")

IE.Navigate ("www.Facebook.com")
IE.Visible = True

Do While IE.Busy: DoEvents: Loop

Application.Wait (Now + TimeValue("00:00:02"))

IE.Document.all.Item("email").Value = sUser
IE.Document.all.Item("pass").Value = sPass
IE.Document.all.Item("loginbutton").Click
End Sub

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM