gpt4 book ai didi

excel - 如何提交登录凭据?

转载 作者:行者123 更新时间:2023-12-04 20:51:36 25 4
gpt4 key购买 nike

这与登录屏幕的提交按钮有关

HTML:

<TD background=/frontend/images/greenback.gif width=302><INPUT type=submit value="Login now" name=submit> </TD>

我在框中输入用户名和密码,但脚本在 .Submit 处停止

Sub GetTable()

'Kills any open IE windows.
On Error GoTo Ignore
Call IE_Sledgehammer
Ignore:

Dim ieApp As InternetExplorer
Dim ieDoc As Object
Dim ieTable As Object
Dim clip As DataObject
Dim UserName As String, Password As String

'Create anew instance of ie
Set ieApp = New InternetExplorer

'Debugging
ieApp.Visible = True

'Opening this page prompts login screen
ieApp.Navigate "CANNOT SHARE, INTERNAL WORK SITE"

'When busy - wait
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop

'Pop up window
On Error GoTo skip_Popup
ieApp.Document.all.item("submitBn").Focus
SendKeys "~"
skip_Popup:

'Login script
On Error GoTo Skip_Login
Set ieDoc = ieApp.Document

'fill in the login form – View Source from your browser to get the control names
With ieDoc.forms(0)
.UserName.Value = "test1"
.Password.Value = "test2"
.Submit
End With

Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
Skip_Login:

'Copy page Info
Set ieDoc = ieApp.Document
Set ieTable = ieDoc.all.item

'Copy Paste the page
If Not ieTable Is Nothing Then
Set clip = New DataObject
clip.SetText "" & ieTable.outerHTML & ""
clip.PutInClipboard

'Location of data
Sheets("Raw Data").Range("E2").PasteSpecial "text"
End If

'Delete any form controls that make it into the sheet
Sheets("Raw Data").DrawingObjects.Delete

'Kills ALL IE windows
Call IE_Sledgehammer
Set ieApp = Nothing
End Sub

这也不重要,我如何只选择页面上的表格而不选择其他所有内容?它没有名字,所以我也被这个名字困住了。

HTML:
<table cellspacing="1" cellpadding="2" align="center" border="0" width="400">

最佳答案

尝试使用属性 = 值 css 选择器

ie.document.querySelector("[name=submit]").click

对于您的表,您最好的选择是通过它与其他元素/属性的关系来定位它。在没有看到更多 html 的情况下无法提供进一步的建议。如果该表中没有唯一的属性或属性=值(其他表中不存在),则将其组合到表中

例如
ie.document.querySelector("table[width='400']")

这是一种不太稳健的方法。

关于excel - 如何提交登录凭据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58287580/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com