gpt4 book ai didi

excel - 如何通过标签、标签名称获取元素,然后点击标签位置(不工作)//镜像iMacros程序(工作)

转载 作者:行者123 更新时间:2023-12-04 22:28:18 25 4
gpt4 key购买 nike

目标:自动运行网络报告,保存到文件,上传到 FTP

问题:无法单击 VBA 中的元素,但我知道我需要采取的路线,因为宏在 iMacros 程序中成功运行 (https://imacros.net/download/)

问题:如何在 VBA 中镜像 iMacro 命令或者在 VBA 中编写的最佳方式是什么?我很高兴得到解决方案,并感谢您抽出时间来帮助我!

HTML:

<frame name="leftFrame" src:"/client1-power/utility/CommonControllerServlet?action=folderAction&subaction=getRootFolders&folderId=null" frameBorder="0" marginHeight="0" noResize="noresize" scrolling="no">

<a title="Workspaces" class="leftnavleaflink" id="itemTextLink5" onmouseover="return true;" onclick="javascript:clickOnFolder("5");" oncontextmenu="showContextMenu("5");return false;" target="mainFrame" shape="">Workspaces</a>

iMacros - 工作:)
VERSION BUILD=12.5.503.8802
TAB T=1
TAB CLOSEALLOTHERS
'SET !PLAYBACKDELAY 0.00
URL GOTO=https://advantage.iriworldwide.com/client1-power/SplashLogin.jsp
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:j_username CONTENT=xxxxx
TAG POS=1 TYPE=INPUT:PASSWORD ATTR=NAME:j_password CONTENT=xxxxx
TAG POS=1 TYPE=INPUT:SUBMIT ATTR=NAME:submitButton
FRAME NAME=leftFrame
TAG POS=1 TYPE=A ATTR=TXT:Workspaces
TAG POS=1 TYPE=A ATTR=TXT:"My Workspaces"
TAG POS=1 TYPE=A ATTR=TXT:XP3
TAG POS=1 TYPE=A ATTR=TXT:"Data for Interactive Edge"
TAG POS=2 TYPE=A ATTR=TXT:"Salty Snacks"
FRAME NAME=mainFrame
TAG POS=1 TYPE=A ATTR=TXT:"26 Weeks - Regions"
TAG POS=1 TYPE=A ATTR=TXT:"13 Weeks - Regions"
TAG POS=1 TYPE=A ATTR=TXT:"13 Weeks - Markets-Parent Company"
TAG POS=1 TYPE=A ATTR=TXT:"52 Weeks - Regions"

VBA 代码 - 不工作 :(
Sub iriAutomation()
Dim objIE As InternetExplorer
Set objIE = New InternetExplorer
objIE.Visible = True

objIE.navigate "https://advantage.iriworldwide.com/client1-power/SplashLogin.jsp"
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
objIE.document.getElementById("usrname").Value = "xxxxx"
objIE.document.getElementById("password").Value = "xxxxx"
objIE.document.getElementById("submitButton").Click
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
'objIE.document.getElementById("5").Click -----NOT WORKING
'objIE.document.parentWindow.execScript "javascript:clickOnFolder(""5"");" -----NOT WORKING
'objIE.document.HTMLDocument.getElementsByTagName ("Workspaces") -----NOT WORKING
'objIE.document.getElementById("itemTextLink5").Click -----NOT WORKING
'objIE.document.getElementById("5").getElementsByTagName("a").click -----NOT WORKING
'objIE.document.HTMLDocument.getElementsByName ("leftFrame") -----NOT WORKING
End Sub

运行时错误“438”:对象不支持此属性或方法

用于帧计数:
enter image description here

最佳答案

了解如何使用 HTTP 请求。

以下内容应该让您登录:

Sub iri()
Dim req As WinHttpRequest
Set req = New WinHttpRequest
Dim doc As HTMLDocument
set doc = New HTMLDocument
Dim reqBody As String
Dim userName As String
Dim pswd As String
userName = "user"
pswd = "12345"
reqBody = "j_username=" & userName & "&j_password=" & pswd & "&login-form-type=pwd&submitButton=Login"
With req
.Open "POST", "https://advantage.iriworldwide.com/client1-power/SplashLogin.jsp", False
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.send reqBody
doc.body.innerHTML = .responseText
End With
End Sub

登录后,您可以操作存储在 doc 中的响应 HTML。 ,随便你。
使用的引用资料:
Microsoft WinHTTP Services, version 5.1

Microsoft HTML Object Library

关于excel - 如何通过标签、标签名称获取元素,然后点击标签位置(不工作)//镜像iMacros程序(工作),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55577249/

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