gpt4 book ai didi

vba - UPS 自动跟踪单击按钮

转载 作者:行者123 更新时间:2023-12-04 22:05:31 27 4
gpt4 key购买 nike

我要访问webpage .然后在测试框中输入一个数字。我能够做到这一点。

之后我想点击 Track 按钮。知道如何点击vba吗?

我已经尝试过以下命令。知道如何找到 Track 按钮的 id 吗?

ie.document.getElementByName("track.x").Click
ie.document.getElementByClass("button btnGroup6 arrowIconRight").Click

假设我们输入跟踪号“1ZW2E2360449018801”,然后单击该按钮,将打开一个新网页。我想点击“发货进度”栏并复制出现的表格。有什么建议么?

最佳答案

这样就搞定了。。

Sub test()
' open IE, navigate to the website of interest and loop until fully loaded
Set ie = CreateObject("InternetExplorer.Application")
my_url = "http://wwwapps.ups.com/WebTracking/track?loc=en_US"

With ie
.Visible = True
.navigate my_url
.Top = 50
.Left = 530
.Height = 400
.Width = 400

Do Until Not ie.Busy And ie.readyState = 4
DoEvents
Loop

End With

' Enter a value in the "Number" text box
ie.Document.getElementById("trackNums").Value = "1ZW2E2360449018801"

' Click the "Submit" button
Set Results = ie.Document.getElementsByTagName("input")
For Each itm In Results
If InStr(1, itm.outerhtml, "Track", vbTextCompare) > 0 Then
itm.Click
exit for
End If
Next

' Click the "Shipment Progress" button
Set Results = ie.Document.getElementsByTagName("h4")
For Each itm In Results
If InStr(1, itm.outerhtml, "Shipment Progress", vbTextCompare) > 0 Then
itm.Click
exit for
End If
Next

' Get the text from the "Shipment Progress Table" and assign to a variable
tbltxt = ie.Document.getElementsByTagName("table")(4).innertext

' process the text as desired
End Sub

关于vba - UPS 自动跟踪单击按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22820892/

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