我正试图通过输入网站来抓取网页并进行搜索,然后复制一些值。
我设法进入网络并输入一些搜索值。但是,我不知道如何从网上读取所需的值。
下面的图片显示了我正在寻找的值以及代码的第一部分。有人可以在最后一步帮助我吗...
我到目前为止所拥有的:
Dim ie As Object
Dim i, x As Integer
Dim objElement As Object
Dim objCollection As Object
Dim StartRow As Integer
'totalPo = Application.WorksheetFunction.CountA(Sheet3.Range("A:A"))
Set ie = New InternetExplorerMedium
With ie
.Visible = True
.navigate "http://xxx"
Do While ie.busy
Application.Wait DateAdd("s", 1, Now)
Loop
'hit IMPORT
Set objCollection = ie.Document.getElementsByTagName("input")
i = 0
While i < objCollection.Length
If objCollection(i).Value = "Import" Then
Set objElement = objCollection(i)
End If
i = i + 1
Wend
objElement.Click
'------------
'hit Oversea
Set objCollection = ie.Document.getElementsByTagName("input")
i = 0
While i < objCollection.Length
If objCollection(i).Value = "Oversea" Then
Set objElement = objCollection(i)
End If
i = i + 1
Wend
objElement.Click
'hit New
Set objCollection = ie.Document.getElementsByTagName("input")
i = 0
While i < objCollection.Length
If objCollection(i).Value = "New" Then
Set objElement = objCollection(i)
End If
i = i + 1
Wend
objElement.Click
vpn = Sheet1.Range("A" & ActiveCell.Row)
'Enter IPN
Set objCollection = ie.Document.getElementsByTagName("input")
i = 0
While i < objCollection.Length
If objCollection(i).Name = "ctl00$ContentPlaceHolder1$txtQuery_VPN" Then
objCollection(i).Value = vpn '
End If
i = i + 1
Wend
End With
'------------
Set objCollection = ie.Document.getElementsByTagName("input")
i = 0
While i < objCollection.Length
If objCollection(i).Name = "ctl00$ContentPlaceHolder1$btnQuery_ItemID" Then
Set objElement = objCollection(i)
End If
i = i + 1
Wend
objElement.Click
Do While ie.busy
Application.Wait DateAdd("s", 1, Now)
Loop