gpt4 book ai didi

html - 我将如何提取此文本

转载 作者:行者123 更新时间:2023-11-27 23:28:30 24 4
gpt4 key购买 nike

我正在查看此网页 -> https://www.fedex.com/apps/fedextrack/?action=track&tracknumbers=671299425542&locale=en_US&cntry_code=us

我想返回交付日期 Thu 3/31/2016 12:16 pm

到目前为止,这是我的代码

Public Sub FedExTracking()

Dim IE As Object
Dim ReturnValue As Object
Dim ProUrl As String
Dim RowCount As Integer
Dim PullText As String
Dim iCounter As Integer

Set IE = CreateObject("InternetExplorer.application")

RowCount = 0

Do While Not ActiveCell.Offset(RowCount, -1).Value = ""

ProUrl = "https://www.fedex.com/apps/fedextrack/?action=track&tracknumbers=" & ActiveCell.Offset(RowCount, -1).Value & "&locale=en_US&cntry_code=us"

With IE
.Visible = True
.Navigate ProUrl
Do Until Not IE.Busy And IE.readyState = 4: DoEvents: Loop
End With


iCounter = 0
Do While iCounter < 8
WaitHalfSec
iCounter = iCounter + 1
Loop


set ReturnValue = IE.document.getElementsClassName("snapshotController_date.dest")(0)

'THIS LINE RETURNS RUN TIME ERROR "91" OBJECT VARIABLE OR WITH BLOCK VARIABLE NOT SET
PullText = ReturnValue.innertext

ActiveCell.Offset(RowCount).Value = PullText & "."

RowCount = RowCount + 1

Loop

IE.Quit
Set IE = Nothing

End Sub

Sub WaitHalfSec()
Dim t As Single
t = Timer + 1 / 2
Do Until t < Timer: DoEvents: Loop
End Sub

只要我不厌倦进入内部文本,我就能够找到并存储它看起来的行。我将如何返回这条线上的日期?

2016 年 3 月 31 日星期四下午 12:16

感谢任何帮助!

最佳答案

试试这个:

ReturnValue = IE.document.getElementsByClassName("snapshotController_date.dest")(0).innerText

即使在您检查它时类名似乎有一个空格,但如果您在 DOM 资源管理器中查看它会有一个句点。它也是类名,而不是 ID,因此您需要使用 getElementsByClassName() 方法并使用它返回的 HTMLCollection 对象。

关于html - 我将如何提取此文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37147209/

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